C++ executable - MSVCR100.dll not found error

2019-03-30 06:26发布

问题:

I've downloaded and compiled an open-source C++ application, Frhed.

When I run the version I've compiled, it demands MSVCR100 and few other dll files (part of Visual C++ redistributable). However, when I run the original precompiled Frhed executable, it runs without any C++ redistributable package installed.

Do I have to modify any compilation options in order to unlink the program from the C++ redistributable libraries?

回答1:

The original program is probably statically linked, whereas you are trying to dynamically link your executable, which results in a smaller file, but a dependency on functions inside MSVCR100.dll (v10 of the Microsoft C Runtime Library), which would have been included inside the executable if you were statically linking.

To statically link DLLs, go into your project properties and change the build mode from MD to MT. In Visual Studio 2010/2012, that project property is C/C++ -> Code Generation -> Runtime Library.



回答2:

The short answer is yes, the longer answer is, well, longer.

The library msvcr100.dll is the 10.0 version (i.e., Visual Studio 2010 version) of the DLL implementation of the C run-time which you probably requested by using the /MD compile option. To avoid using the dynamically linked version of the run-time you can use the /MT option instead and statically link the run-time.

Alternatively, you can redistribute msvcr100.dll (and other files) along with your program.