1. GCC is a GNU compiler collection (GNU compiler suite) or simply a compiler. It can compile many programming languages (including C, C + +, Objective-C, FORTRAN, Java, etc.).
2. When your program has only one source file, you can directly compile it with GCC command.
3. However, when your program contains many source files and you compile them one by one with GCC command, you are prone to confusion and heavy workload
4. Therefore, the make tool appears. The make tool can be regarded as an intelligent batch processing tool. It does not have the function of compiling and linking, but uses a method similar to batch processing – compiling and linking by calling the commands specified by the user in the makefile file file.
5. What is a makefile? In short, it is like the score of a song. The make tool is like a conductor. The conductor directs the whole orchestra how to play according to the score, and the make tool compiles and links according to the commands in the makefile.
6. The makefile command contains the command to call GCC (or another compiler) to compile a source file.
7. In some simple projects, makefiles can be manually controlled, but when the project is very large, handwritten makefiles are also very troublesome. If you change the platform, makefiles have to be modified again.
8. Cmake tool appears at this time. Cmake can easily generate makefile files for the above make. Of course, cmake has other functions, that is, it can generate makefiles that can be used by the corresponding platform across platforms. You don’t have to modify them yourself.
9. But what does cmake generate a makefile based on? It also generates a makefile based on a file called cmakelists.txt (scientific name: configuration file).
10. Who wrote the cmakelists.txt file at the end? Kiss, you wrote it yourself.
11. Of course, if you use IDE, like vs, it can help you do it. You just need to click the triangle
12. Then qmake. What is qmake? Let’s talk about QT first. QT is a cross platform C + + graphical user interface application development framework. It can be used to develop both GUI programs and non GUI programs, such as console tools and servers. In short, it is the third-party library of C + +. Using this library, you can easily generate the graphical interfaces of windows, Linux, Mac OS and other platforms. Now QT also includes the functional modules commonly used in developing various software (network, database, XML, multithreading, etc.), which is more convenient and simple than using C + + (only with standard underwear).
13. You can simply use QT to realize very complex functions because QT extends C + +. You write one line of code. QT helps you write hundreds of thousands of lines behind it. These extra lines of code rely on QT’s proprietary MOC compiler (the meta object compiler) and UIC compiler (user interface compiler) to re translate your line of code. The problem is that before compiling the program, you must call MOC and UIC to preprocess the QT source file, and then call the compiler to compile. The ordinary makefile file mentioned above is not applicable. It cannot preprocess the QT source file. So qmake came into being.
14. Qmake tool is made by QT company to generate QT special makefile file, which can automatically and intelligently call MOC and UIC to preprocess and compile the source program. Of course, qmake must also be cross platform. Like cmake, it can generate corresponding makefiles for various platforms.
15. Qmake generates the corresponding makefile according to the QT project file (. Pro). Project files (. Pro) are relatively simple. Generally, you can write by yourself, but they are generally automatically generated by QT creator, QT’s development environment. You just need to press the evil triangle.
16. Not yet. Because qmake is very simple and easy to use, supports cross platform, and can be independent of its IDE, you can also use it in non QT projects. You can still generate ordinary makefiles. Just add config – = QT to the pro file.
17. What’s the difference between qmake and cmake?
Sorry, cmake also supports QT programs. Cmake can also generate special makefiles for QT programs,
Cmakelists.txt of cmake is a little more complicated than the pro file of qmake.
Qmake is tailored for QT and is very convenient to use, but cmake is more powerful than qmake.
For general QT projects, you can directly use qmake. The powerful function of cmake is not available to ordinary people.
When your project is very large, there are some sub projects in QT and some sub projects in other languages. It is said that cmake will be convenient, and I haven’t tried it.
This work adoptsCC agreement, reprint must indicate the author and the link to this article