Reputation: 401
I am using visual studio 2013 to compile c++ code on the command line (cl.exe). I understand that when using the ide, there is an option to compile in release mode or debug mode.
Does this option exist for the command line compiler as well? How can it be accessed?
I have looked at all the options attached to cl.exe on the Microsoft website, but none seem to fit. Also the Microsoft website seems to only include inductions on how to compile for release via the ide.
Upvotes: 2
Views: 7580
Reputation: 7163
The tool you want to use is MSBuild.exe
.
From a developer command prompt, run msbuild /?
for all the options.
Examples:
MSBuild MyApp.sln /t:Rebuild /p:Configuration=Release
MSBuild MyApp.csproj /t:Clean /p:Configuration=Debug;TargetFrameworkVersion=v3.5
If you want to do this with cl.exe/link.exe, there is a big "it depends" on what switches you want. If you are after the pure defaults, it still might depend on how your project might look in Visual Studio. An easy way to do this is to create a simple project in VS, look at project properties for Configuration Properties
and see the Command Line
for each. Or go through help with cl /?
and link /?
For a basic project that might be:
Release:
/GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /Fd"Release\vc140.pdb" /Zc:inline /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\ConsoleApplication2.pch"
Debug:
/GS /analyze- /W3 /Zc:wchar_t /ZI /Gm /Od /Fd"Debug\vc140.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\ConsoleApplication2.pch"
As you can see, there are many options, no single answer, however the big differentiation for Release
builds is /D "NDEBUG"
and /O2
Upvotes: 5