Get rid of msvcr120.dll/msvcp120.dll dependency in

2019-04-23 04:44发布

问题:

I know that there are some questions about how to include msvcr120.dll/msvcp120.dll into your project.

But I want to drop that dependency. I compile the program in Release version, in Visual Studio 2013. I do not depend on any VS-specific commands (#pragma etc.) or precompiled headers etc.

I want to compile it to one single release .exe and provide it to user WITHOUT demanding him to install VC++ Redistributes for VS (the user will be working on Windows 7, Windows 8, maybe Windows XP).

Is that possible? If so, how?

回答1:

You can statically link the runtime to your project by setting the /MT flag. You can find this option in Visual Studio 2013 under Project > [ProjectName] Properties... > Configuration Properties > C/C++ > Code Generation > Runtime Library. Make sure to only set it for the Release configuration.



回答2:

From the comments. To remove the requirement of possibly needing the redistributable you can build your application with the static runtime (/MT option) instead of either of the dynamic runtime choices.