c++visual-studio-2010command-linecl.exe

Visual Studio from the command line


I am using Visual Studio 2010 to create a small c++ executable. Since I now want to use a different editor I have to call cl.exe and link.exe from the command line.

It is great that VS provides the used command-lines in Project->Properties->C/C++->Commandline and ->Linker->CommandLine
however, they dont work quite like they should:

In the compiler command line I added /c and removed the file-renaming-stuff /Fp /Fa /Fo /Fd (http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx)

In the linker command line I removed the /MANIFEST and /Manifest (http://msdn.microsoft.com/en-us/library/y0zzbyt4.aspx)

the result is this:

cl.exe main.cpp /c /Zi /nologo /W3 /WX- 
    /O1 /Oi /Os /Oy /GL 
    /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" 
    /Gm- /EHsc /GS /Gy /fp:precise 
    /Zc:wchar_t /Zc:forScope /Gd /analyze- /errorReport:queue 


link.exe *.obj /OUT:"test2.exe" /INCREMENTAL:NO /NOLOGO 
    "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" 
    "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" 
    "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" 
    /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" 
    /DEBUG /PDB:"F:\prj\visualstudio2010\test2\Release\test2.pdb" 
    /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF 
    /PGD:"F:\prj\visualstudio2010\test2\Release\test2.pgd" 
    /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE 

The resulting exe works the same way as if i had built it using the GUI, but the problem is that it is 145kb instead of 22kb for some reason. Should I just accept that or is there something obvious that the GUI has and that I am missing?


Solution

  • You can see full build log, including command line switches, in the project output directory, program_name.log file. You can also build the project from command line: http://msdn.microsoft.com/en-us/library/vstudio/xee0c8y7.aspx