Statically linking libs in Visual Studio

让人想犯罪 __ 提交于 2019-12-12 03:39:38

问题


When you choose /MTd static linking in Visual Studio, would it try to link to each lib statically or there are some exceptions to system libs?


回答1:


Description: /MTd: Defines _DEBUG and _MT. This option also causes the compiler to place the library name LIBCMTD.lib into the .obj file so that the linker will use LIBCMTD.lib to resolve external symbols.

From what I can see there is no static linking. If you want to do static linking you need to use ILMerge. And even then you should not attempt to merge in the required .Net Framework references as they often reference others which you may miss. It may not even be possible as they use GAC for referencing.




回答2:


The /MT and /MD flags only define how the C/C++ runtime library is linked in. It has no effect on other libraries, system or user defined.

The system libraries, such as kernel32.lib, user32.lib, etc) are import libraries - there is no static library to link with.



来源:https://stackoverflow.com/questions/4796962/statically-linking-libs-in-visual-studio

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