Is it possible to mix static, multi-threaded, DLL libraries in one project?

一世执手 提交于 2019-12-10 15:53:21

问题


Is it possible to use distinct libraries A, B, C in the same project in Visual Studio, where A is a static library, B is multi-threaded and C is a multi-threaded DLL? Or do they all have to be the same type for a single .exe output?

Edit: Sorry, A is a single-threaded static library. B is a multi-threaded static library, C is a multi-threaded DLL. (I guess A and B are the same from the linker's point of view?)


回答1:


Are you talking about libraries compiler with different CRT linking type(static, dll)? If yes, then it's impossible.




回答2:


You can freely mix static and dynamic libraries, so long as they all use the same run-time libs.

In Properties -> General -> Configuration Type -> set this to Static Library or Dynamic Library for the libraries A and B you want to static or dynamic.

In Properties -> C/C++ -> Code Generation -> Runtime Library -> Every library which will be linked together must use the same run-time library, for example Multi-Threaded Debug DLL.

Thus you could do:
A - Config Type: Static Library. Runtime Lib: Multi-threaded Debug DLL. (yes this is ok)
B - Config Type: Dynamic Library. Runtime Lib: Multi-threaded Debug DLL

These two libs could be linked into the same exe.




回答3:


Not sure what B is but the general idea is yes.

A will get compiled directly into the exe B Not sure about what this one is C Yes, functions within this library will be linked at runtime.



来源:https://stackoverflow.com/questions/2285408/is-it-possible-to-mix-static-multi-threaded-dll-libraries-in-one-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!