Recently, I read c ++ primer 5 and found that the nmake tool of vc11 is used to compile files. Similar to the makefile tool in Linux, it is easy to clear and compile files with one click. You just want to compile some small code segments using this method, so you don't have to open the bulky vs2012.
Use the CL command line to compile the program:
Write a simple bat script to find the configuration file of the VC environment variable:
@echo offcall "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"call NMAKEcmd
Use CL command lines to compile C ++ files:
cl /EHsc /nologo /I.. filname.cpp
Nmake actually calls CL in batches to compile the link target file.
The following describes how to configure makefile.
A simple makefile example is used to compile the wordcount. CC file:
CPP = clCPPFLAGS = /EHsc /nologo /I.. $(LOCFLAGS)LOCFLAGS = -I..\7 -I..\6OBJECTS = WordCount.exeall: $(OBJECTS) .cpp.obj: $(CPP) $(CPPFLAGS) /c $< .obj.exe:$(CPP) $(CPPFLAGS) $<clean:del *.obj core *.stackdumpclobber: cleandel *.exe
Write a BAT file and call makefile:
@echo offcall "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"call nmake -nologocmd
Or add vsvar to the environment variable and open CMD in this folder:
Compile: cmd: nmake
Clear: cmd: nmake clean
Delete: cmd: nmake clobber