1、在command line下开发。一些简单的C++程序,没必要启动整个IDE,使用VC7.1的编译器在命令行下即可顺利的工作。要在command line下工作,必须做以下这些事情:(1)打开cmd之后,运行vsvars32.bat(位于$prefix/common7/tools目录下) (2)运行cl <sourcefilename>即可。在cl编译的过程中,会有一些warning出现,如C++ Exception的问题,默认情况下,cl打开了exception使用的开关,如果代码中没用的话,会出warning,这次可以按照cl输出信息的 提示,加上/EHsc开关,即cl /EHsc helloworld.cpp,此时编译就没warning了。
2、碰到问题时,随时看 MSDN的 .NET Development --> Visual Studio .NET --> Product documation --> Visual C++ --> Building a C/C++ Program 里面的相关内容即可!
2、碰到问题时,随时看 MSDN的 .NET Development --> Visual Studio .NET --> Product documation --> Visual C++ --> Building a C/C++ Program 里面的相关内容即可!
3、VS .NET在编译project的时候,都会在debug目录下生成一个BuildLog.html文件,这个文件中包含了编译时用到的所有命令行,对我们 理解IDE的编译工作很有帮助,这里可以清晰的看到IDE是如何调用cl和link两个工具来编译、链接整个工程的,这里给出一个example(具体参 数看cl和link的命令行帮助):
Command Lines Creating temporary file "d:\WUTemp\HelloMsg\Debug\RSP000001.rsp" with contents
[
/Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Gm /EHsc /RTC1 /MLd /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Wp64 /ZI /TC
.\HelloMsg.C
]
Creating command line "cl.exe @d:\WUTemp\HelloMsg\Debug\RSP000001.rsp /nologo"
Creating temporary file "d:\WUTemp\HelloMsg\Debug\RSP000002.rsp" with contents
[
/OUT:"Debug/HelloMsg.exe" /INCREMENTAL /NOLOGO /DEBUG /PDB:"Debug/HelloMsg.pdb" /SUBSYSTEM:WINDOWS /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
.\Debug\HelloMsg.obj
]
Creating command line "link.exe @d:\WUTemp\HelloMsg\Debug\RSP000002.rsp"
Output Window Compiling...
HelloMsg.C
Linking...
Results Build log was saved at "file://d:\WUTemp\HelloMsg\Debug\BuildLog.htm"
HelloMsg - 0 error(s), 0 warning(s)
Command Lines Creating temporary file "d:\WUTemp\HelloMsg\Debug\RSP000001.rsp" with contents
[
/Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Gm /EHsc /RTC1 /MLd /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Wp64 /ZI /TC
.\HelloMsg.C
]
Creating command line "cl.exe @d:\WUTemp\HelloMsg\Debug\RSP000001.rsp /nologo"
Creating temporary file "d:\WUTemp\HelloMsg\Debug\RSP000002.rsp" with contents
[
/OUT:"Debug/HelloMsg.exe" /INCREMENTAL /NOLOGO /DEBUG /PDB:"Debug/HelloMsg.pdb" /SUBSYSTEM:WINDOWS /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
.\Debug\HelloMsg.obj
]
Creating command line "link.exe @d:\WUTemp\HelloMsg\Debug\RSP000002.rsp"
Output Window Compiling...
HelloMsg.C
Linking...
Results Build log was saved at "file://d:\WUTemp\HelloMsg\Debug\BuildLog.htm"
HelloMsg - 0 error(s), 0 warning(s)