Reputation: 1
Every time I write a C program using Visual Studio 2013 the .exe file only runs on my PC. When I copy that .exe file to other PC it doesn't run. But if I use Code Blocks IDE instead the .exe file runs in all PCs. Why? and how can I make a 'C program' written in 'Visual Studio 2013' run on every PC?
Upvotes: 0
Views: 288
Reputation: 4174
In your project settings, change the Runtime Library support to Multi-threaded (/MT) instead of the default, which is Multi-threaded DLL (/MD). This will cause your .exe to be statically linked, and it won't need to look for the runtime libraries on the target machine. (I think it's under C/C++ Code generation, but I don't have visual studio 2013 installed at that moment to verify that).
The resulting .exe will be bigger (because it has to link in all the parts of the runtime that you use), but it simplifies deployment on other machines - no need to install the redist package.
Upvotes: 0
Reputation: 53016
It's because of the 2013 runtime libraries1, you need to download the redistributable and install it into the target computer.
You can download it from here.
1The file is called msvcr120.dll
if you compiled with the VS 2013 ("v120") platform toolset, and otherwise follows the pattern msvcrNNN.dll
.
Upvotes: 3