[英]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.我的代码在 VS2019 版本 x86 模式下运行良好,但在调试模式下运行良好。 Is there any way to use the release mode feature in the command line?
有没有办法在命令行中使用发布模式功能? For example an option for CL or link.exe.
例如 CL 或 link.exe 的选项。 The CL command line syntax is
CL 命令行语法是
CL [option...] file... [option |
CL [选项...] 文件... [选项 | file]... [lib...] [@command-file] [/link link-opt...]
文件]... [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.下面是 MSVC 编译器选项的列表: MSVC 编译器选项有一些优化选项,例如
/O1
/O2
,但它们不会产生与 VS 版本构建相同的结果。 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.我发现我的代码的正确选项是
/MD
用于运行时库设置。 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. Visual Studio 的项目配置属性将准确告诉您每个构建配置中使用的编译器和 linker 选项。 See: https://docs.microsoft.com/en-us/cpp/build/working-with-project-properties?view=vs-2019
请参阅: https://docs.microsoft.com/en-us/cpp/build/working-with-project-properties?view=vs-2019
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.