Make, cmake, qmake, and makecmakeqmake

Source: Internet
Author: User

Make, cmake, qmake, and makecmakeqmake
Author: Hui changge
Link: https://www.zhihu.com/question/27455963/answer/89770919
Copyright belongs to the author. For commercial reprint, please contact the author for authorization. For non-commercial reprint, please indicate the source.

1. gcc is the GNU Compiler Collection (the GNU Compiler suite). It can also be considered as a Compiler, it can compile many programming languages (including C, C ++, Objective-C, Fortran, Java, and so on ).

2. When your program has only one source file, you can directly compile it using the gcc command.

3. However, when your program contains many source files and uses gcc commands to compile them one by one, you will be easily confused and have a heavy workload.

4. The make tool appears.
The make tool can be regarded as an intelligent batch processing tool, which does not have the compilation and link functions, instead, it is compiled and linked by calling the user-specified commands in the makefile file in a way similar to batch processing.

5. What is makefile? Simply put, it is like the music score of a song. The make tool is like a conductor. The conductor directs the whole orchestra to play according to the music score. The make tool compiles and links based on the commands in the makefile.

6. The makefile command contains the command to compile a source file by calling gcc (or another compiler.

7. makefile can be manually used in some simple projects, but when the project is very large, handwriting makefile is also very troublesome. If you change the platform makefile, You have to modify it again.

8. Now the Cmake tool is available, and cmake can generate makefile files more easily for the make tool above. Of course, cmake also has other functions, that is, it can generate makefiles that can be used by the corresponding platform across platforms, and you do not have to modify them yourself.

9. Why does cmake generate makefile? You need to generate a makefile named cmakelists.txt (Student name: configuration file.

Who writes the final cmakelists.txt file? You wrote it yourself.

11. Of course, if you use IDE, similar to VS, it can be done for you. You just need to click the triangle.

12. Next we will talk about qmake and qmake. Let's talk about Qt. Qt is a cross-platform C ++ graphical user interface application development framework. It can be used to develop GUI programs or non-GUI programs, such as console tools and servers. In short, it is a third-party library of C ++. Using this library, you can easily generate graphical interfaces for windows, Linux, MAC OS, and other platforms. Currently, Qt also includes functional modules (networks, databases, XML, and multithreading) that are generally used to develop various software ), it is more convenient and easier than using C ++ (with only standard underpants.

13. you can use Qt to implement very complex functions simply, because Qt extends C ++. You write a line of code and Qt helps you write hundreds of thousands of lines behind it, the extra code relies on The proprietary moc Compiler (The Meta-Object Compiler) and uic Compiler (User Interface Complier) of Qt to re-translate your line of code. The problem is that you must call moc and uic to pre-process the Qt source file before calling the compiler to compile the program. The general makefile mentioned above is not applicable, and it cannot pre-process the qt source file. Therefore, qmake is generated.

14. The qmake tool is manufactured by Qt to generate a dedicated Qt makefile file. This makefile can automatically and intelligently call moc and uic to pre-process and compile the source program. Qmake must also be cross-platform. Like cmake, it can generate makefile files for various platforms.

15. qmake generates the corresponding makefile Based on the Qt project file (. pro. Project file (. pro) relatively simple. Generally, You can manually write the project, but it is generally automatically generated by Qt Creator in the development environment of Qt, you just need to press the evil triangle to finish.

16. since qmake is simple, easy to use, supports cross-platform, and can be independent from its IDE, you can also use it in Non-Qt projects to generate common makefiles, you only need to add CONFIG-= qt to the pro file.

17. What is the difference between qmake and cmake? Sorry, cmake also supports the Qt program. cmake can also generate the special makefilefor the qt program. It is just that cmakelists.txt of cmakeis more complex than qmake's pro file. Qmake is tailored for Qt and is very convenient to use, but the cmake function is more powerful than qmake. You can use qmake directly for general Qt projects. The powerful functions of cmake are not commonly used. When your project is very large, there are some child projects in qt and some molecular projects in other languages. It is said that it is convenient to use cmake, and I have never tried it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.