This article is a supplement to the previous article (http://www.cnblogs.com/LCCRNblog/p/4532643.html), so you need to look at the previous article first.
Recently, when writing code, you need to execute the generated C + + source code file by command, so you need to learn about how to use commands to compile and connect C + + original files in a Windows environment. This article is a self-groping practice to draw. As a starting point for yourself, follow up with a deep understanding of this knowledge.
1. Preparation
Write the main.cpp header.h header.cpp three source code files and put them in a folder test.
2. Writing NMAKE files
Create the Hello.mk file in the test folder and write the following script
foo:main.obj header.obj -EHSC main.obj header.obj-o foomain.obj:main.cpp -ehsc-c main.cppheader.obj:header.h header.cpp -EHSC-C header.cpp Clean: *.obj *.exe
Note that the script hollow lattice needs to be preserved, cannot be arbitrarily added and deleted. As for why, I am not very clear, follow-up slowly understand learning.
In the course of practice, I put "header.obj:header.h header.cpp" This line of Header.h removed, re-execute the script file, still able to pass, this reason I am not quite clear, because I have just touched on this knowledge, but also need to further try to further understand the principles.
Then open cmd, navigate to the test file path, first execute Vcvarsall.bat (the method is covered in the previous article), and then execute the following command
nmake/f hello.mk
The Foo.EXE executable file is generated in the Test folder.
If you execute the following command
nmake/f hello.mk Clean
All *.obj and *.exe generated in the test folder will be deleted.
Using the NMAKE tool to compile the connection C + + source code in a Windows environment