I'm just trying to understand why in Windows there are somethings so complicated....
msvcrXXXX.dll is the DLL for the C runtime library. msvcpXXXX.dll is the DLL for the C++ runtime library.
One or both of these dependencies will be added to your binary if you are building using /MD or /MDd, which are the defaults specified by Visual Studio when you create a new C++ project. Using either of these flags indicates that you want your program to link with the DLL version of the C/C++ runtime. You can change the defaults under Project Properties->Configuration Properties->C/C++/Code Generation/Runtime Library.
If you change your project to use /MT or /MTd, then your application will not generate references to either of the DLLs listed above, because the C/C++ runtimes will be linked directly into your program. For most simple programs, this will not cause any problems. However, if your program is broken up into several DLLs that all are built using these flags, then each DLL will maintain a copy of the referenced CRT functions and static data, and you may run into memory allocation/freeing problems. To avoid these, you need to make sure that objects allocated within a given DLL are also freed in that same module.
In general, it is more efficient to use the /MD and /MDd flags for applications that have multiple modules (DLLs), because all of those modules will share a single copy of the C/C++ runtime libraries and their associated data structures within the application process.
For simple, single-module applications, though, feel free to build using /MT or /MTd.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With