Static Runtime Library Linking for Visual C++ Express 2008

浪尽此生 提交于 2019-12-08 15:14:53

问题


How do you tell Visual C++ Express 2008 to statically link runtime libraries instead of dynamically? My exes do not currently run on computers w/o some sort of VS installed and I would love to change that. :)


回答1:


Sorry, I do not have VC++ Express to test, but in Standard edition I use Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library. Dll and Dll Debug are for dynamic linking.




回答2:


Are you 100% sure that you want to do this? Please consider that if you do and there is a security vulnerability found in the runtime library, Microsoft will not be able to patch your application via Windows Update.

Another solution is to package the Visual C++ Runtime Redistributable with your application. It installs very fast and does not require Visual Studio. It is also important to note that you should not distribute code linked against the debug runtime libraries as those do require Visual Studio. See this blog post for more information on packaging the redistributable.

EDIT: With that said, it's up to you. My point is simply that you should not disregard dynamic linking based solely on the idea that users must have "some sort of VS installed", which is not true.




回答3:


See the answer to this question: How do I make a fully statically linked .exe with Visual Studio Express 2005 ?. It's for VS2005 Express but the answer still holds.

For the C-runtime go to the project settings, choose C/C++ then 'Code Generation'. Change the 'runtime library' setting to 'multithreaded' instead of 'multithreaded dll'.

If you are using any other libraries you may need to tell the linker to ignore the dynamically linked CRT explicitly.




回答4:


You can install the C runtime redist on the target machine and you're executable would run there as well with dynamically linked C runtime.

(Oh sorry, that had already been mentioned).



来源:https://stackoverflow.com/questions/2035287/static-runtime-library-linking-for-visual-c-express-2008

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