简体   繁体   English

Visual Studio 2013选项

[英]visual studio 2013 options

如果.lib文件用于静态链接,而.dll文件用于动态链接,为什么要在C / C ++->代码生成->运行时库选项中指定,则在构建显式静态库时(即,创建.dll时)选择多线程或多线程DLL。 lib)还是在构建项目并链接到.lib库时?

Visual Studio allows you to specify how the CRT is going to be integrated into your project under C/C++->Code Generation->Runtime Library . Visual Studio允许您在C/C++->Code Generation->Runtime Library下指定如何将CRT集成到项目中。 This project setting controls how C/C++ routines used explicitly or internally (eg exception functions or STL routines) are going to be linked to your project. 该项目设置控制如何将显式或内部使用的C / C ++例程(例如,异常函数或STL例程)链接到您的项目。

You can create a static library which uses the CRT dynamically or statically by specifying the /MT or /MD flag during compilation. 您可以通过在编译过程中指定/MT/MD标志来创建静态或动态使用CRT的静态库。

Regarding advantages/disadvantages I'm linking this answer which features a pretty good list of points to keep in mind. 关于优点/缺点,我将链接此答案 ,其中列出了很多要记住的要点。

One last thing to notice: if your project is going to use multiple static libraries (including your .lib file), you should make sure that this CRT option matches during the linking phase otherwise you might encounter the (in)famous LNK4098 error . 需要注意的最后一件事:如果您的项目要使用多个静态库(包括.lib文件),则应确保在链接阶段此CRT选项匹配,否则可能会遇到(著名的)LNK4098错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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