8
votes

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?

2
You will have to use the static runtime if you do not want the redistributable. - drescherjm
Should I use /MT option then? And the same for any of .lib I compile and include into project? What with 3rd-party .dll files? - PolGraphic
#pragma and most VS specific commands don't depend on the msvcr. Having globals depends on the c++ runtime. It's also the thing that calls main. You need that code. However, as drescherjm says, you can embed that lib code in your exe (via the /MT or /MTd option), and then you don't need a seperate dll file. - Mooing Duck
What with 3rd-party .dll files? You would have to avoid these. Although I thought you were already doing that with the single exe. - drescherjm
@drescherjm yes, I'm sorry - it was a simplification for the question. I want single .exe + opengl dll files (which are not part of VC and that's why I ignored them in the first place). Can you make an answer from your comment about MT? I can accept it as an answer. - PolGraphic

2 Answers

13
votes

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.

3
votes

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.