I am trying to compile an application in C++ that works without the .net framework or visual studio run times having to be installed. I have done some research and found this article from MSDN showing how to compile native C++ code. However when I followed this example, after running the generated executable on a computer without the visual studio run times, I get an error MSVCP100D.dll is missing from your computer. I know that it is possible to fix a similar error with GCC by typing -static-libgcc -static-libstdc++ to generate a static binary. Is it possible to do this using Visual Studio 2010? The reason I wish to do this is that I enjoy working with Visual Studio IDE, but I would like my code to be portable to other OS’s like UNIX. Thank you!
Note: I thought it might be helpful to post the code I am compiling for testing purposes.
#include <iostream>
int main()
{
std::cout << "Hello world";
}
MSVCP100D.dllis the debug version ofMSVCP100.dll. They are the dynamic link libraries that implements the C run-time libraries. This is needed to implement the C++ standard libraries in Visual C++ 2010.The compiler links against
MSVCP100D.dllin debug mode. There should be aMSVCP100D.dllon your development machine when you installed the compilers that came with Visual Studio 2010. If this isn’t so then something went wrong with the installation.The compiler links against
MSVCP100.dllin release mode. If you plan to deploy your application, you need to compile in release mode and distribute the release versions of the binary. Do not distribute the debug versions of the binary.If even after doing that you still get errors, you may need to install the Visual C++ 2010 runtimes.
The installers are available to download:
If you rather not link against the dynamic library, you can statically link the C run-time libraries into your application by specifying the
/MTcompiler switch as described here.Note that static linking will increase the size of the application binary, and if the C run-time libraries are updated (e.g. security/performance improvements) the application will not use them unless you recompile the application.
I highly recommend that you install the redistributable package anyway since lots of other applications you may use might need the libraries.