Why is msvcrt.dll automatically linked even if I use only os api?

I use vs2010, and whenever I build any Windows application (without using mfc or the standard library - only raw api), msvcrt.dll gets attached to it. There are many applications that are compiled on vs but do not have this dependency.

How to remove msvcrt.dll dependency from my application.

+4
source share
1 answer

This is a C runtime library, and you cannot create a C ++ program without runtime.

For Visual Studio 2010, you will have msvcr100.dll actually linked, as it is the MSVC runtime for this version of the compiler. The usual old msvcrt.dll is the MSVC6 runtime, which now ships as a component of the Windows system. If your executable refers to msvcrt.dll, you must refer to something else, which in turn refers to msvcrt.dll, since nothing in VS2010 will depend on the MSVC6 runtime.

You can remove the dependency on msvcr100.dll using static binding (/ MT) , but there are pros and cons to choosing this option. If you use static linking, you can distribute your application as a single executable. If you use dynamic linking, you need to install a runtime on each target computer. Using some third-party libraries will force you to use dynamic linking so that the runtime can be shared between your executable and third-party libraries.

+7
source

Source: https://habr.com/ru/post/1385638/


All Articles