1. The birth of GCC!
In 1985, on a dark night when his fingers were out of sight, a strange man with a beard, a short figure, and messy hair began to write a set of C language compilers. This ecphony, later known as the "greatest programmer" and "father of free software", was Richard Stallman. After two years of hard work, Richard Stallman, who has a longer beard and messier hair, has completed the first version of the C compiler, which he calls GNU C Complier, which is now the source of the famous GCC. Later, GCC developed rapidly, and now GCC can compile not only C language, but also C++, Fortran, Pascal, Objective-C, Java, Ada and other languages. In the 80s and 90s of the last century, the CPU frequency, hard disk size, and memory size of personal computers were all measured in MB or even KB, and the number of program files that needed to be compiled was small, and GCC commands were enough to deal with it.
Second, new troubles have appeared! (make & makefile)
With the improvement and popularization of computer performance, a software project contains more and more source files, such as linux, which is easily confusing and workloaded, which is easy to confuse and workloaded, which will make people crazy.
Richard Stallman and Roland McGrath co-developed make and makefile to solve this problem. The make tool can be seen as an intelligent batch processing tool, which does not have the function of compiling and linking, but uses a method similar to batch processing - by calling the commands specified by the user in the makefile file. What is a makefile? The makefile is a script file, simply like the score of a song, the make tool is like a conductor, the conductor directs the entire orchestra to play according to the score, and the make tool is compiled and linked according to the commands in the makefile. The makefile command contains commands to call gcc (or another compiler) to compile a source file.
3. New troubles have arisen again! (Cmake & CMakelist)
The makefile can be written by hand under some simple projects, but when the project is very large, it is also very troublesome to write the makefile by hand. And makefiles for different platforms have appeared one after another, including GNU make, QT's qmake, Microsoft's MSnmake, BSD Make(pmake), Makepp, etc. These Make tools follow different specifications and standards, and the Makefile format they perform varies widely. This poses a serious problem: if the software wants to be cross-platform, it must be able to compile on different platforms. If you use the Make tool above, you have to write a makefile for each standard, which will be a crazy job, and if you change the platform makefile, you will have to re-modify it.
So, at this time, the tool Cmake appeared, and Cmake can generate a makefile file for the above make more easily. Of course, cmake also has other functions, that is, it can generate makefiles that can be used on the corresponding platform across platforms, and you don't have to modify it yourself. cmake is the upper layer of Makefile, and their purpose is to produce portable makefiles and simplify the enormous workload of writing makefiles by yourself. But what does cmake use of to generate a makefile? It also needs to generate a makefile based on a file called CMakeLists.txt file (scientific name: configuration file). In the end CMakeLists.txt who writes the document? Of course, you wrote it yourself.
Fourth, new troubles have appeared again! (Ninja)
As software engineering becomes larger and more complex, the problem of slow execution speed of make becomes more and more serious.
As a result, a Google programmer launched Ninja, a speed-focused build tool. Ninja does not have all kinds of advanced features, the syntax and usage are very simple, and it specifies what to do in detail, so it starts compiling very quickly. According to real-world tests: with more than 30,000 source files, it is also possible to start a real build in 1 second. In contrast, Makefiles written by senior engineers also take 10-20 seconds to start building.
5. The perfect ending so far!
Cmake can generate .ninja and .makefile tools. Because many people are not familiar with how to write makefile files and ninja files, cmake only needs a simple description of the source code file (that is, CMakeLists.txt file) to automatically generate a project makefile file or ninja file, and then start compiling through ninja or make.
5 minutes to understand make/makefile/cmake/nmake
Recently, have you been made by make, cmake, makefile... ... These things are dizzy, look at the following article, maybe you can understand clearly.
1. gcc It is the GNU Compiler Collection, or simply a compiler, which can compile many programming languages (including C, C++, Objective-C, Fortran, Java, etc.).
When our program has only one source file, we can compile it directly with the gcc command.
But what if our program contains many source files? When compiling with gcc commands one by one, it is easy to get confused and work-intensive, so the following make tool appears.
2. make The make tool can be seen as an intelligent batch processing tool, which does not have the function of compiling and linking, but uses a method similar to batch processing - by calling the commands specified by the user in the makefile file.
3. makefile What is this?
Simply put, just like the score of a song, the make tool is like a conductor, the conductor directs the entire orchestra to play according to the score, and the make tool compiles and links according to the commands in the makefile. The makefile command contains commands to call gcc (or another compiler) to compile a source file.
The makefile can be taken manually in some simple projects, but when the project is very large, handwritten makefile is also very troublesome.
4. cmake cmake can easily generate a makefile file for the make above. Of course, cmake has other better functions, that is, it can generate makefiles that can be used on the corresponding platform across platforms, so we don't have to modify it ourselves.
But what does cmake use of to generate a makefile? It also needs to generate a makefile based on a file called CMakeLists.txt file (scientific name: configuration file).
5. CMakeList.txt In the end CMakeLists.txt who writes the document? Dear, it is written by your own hand.
6. nmake What is nmake?
nmake is a side command in Microsoft Visual Studio, which needs to install VS, which can actually be said to be equivalent to linux's make, understand?
Transferred from:
The hyperlink login is visible.
The hyperlink login is visible.
The hyperlink login is visible.
|