Tutorial :Static Runtime Library Linking for Visual C++ Express 2008



Question:

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. :)


Solution: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.


Solution: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.


Solution: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.


Solution: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).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »