简体   繁体   中英

How to set release/debug mode to compile a cpp file at a command prompt using Microsoft C++ toolset

I have a code that works fine in VS2019 release x86 mode but not in debug mode. Is there any way to use the release mode feature in the command line? For example an option for CL or link.exe. The CL command line syntax is

CL [option...] file... [option | file]... [lib...] [@command-file] [/link link-opt...]

Here is the list of MSVC compiler options: MSVC Compiler Options There are some optimization options such as /O1 /O2 but they don't produce the same results as the VS release build. Am I searching for the wrong thing? Thank you in advance for your help.

Update

I found out the correct option for my code is /MD for Runtime Library setting. So using the following line in command prompt, the release-mode results are reproduced:

>cl /MD app.cpp

Visual Studio's configuration properties for your project will tell you exactly what compiler and linker options are being used in each build configuration. See: https://docs.microsoft.com/en-us/cpp/build/working-with-project-properties?view=vs-2019

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM