Can I bind MSVCRT statically with mingw?

I have a C program that I am compiling using mingw on Windows. It works fine, but requires MSVCRT.DLL . I want to link this statically (as I can do in Visual Studio). Is it possible?

I tried the -static flag before gcc and it made no changes.

What about a C ++ program that also uses the standard C ++ library?

+7
c ++ c dll mingw static-linking
source share
3 answers

I believe that MinGW does not use a static runtime library for copyright reasons.

You might try to use newlib ( http://sourceware.org/newlib/ ) to create an executable that does not reference msvcrt.dll

+9
source share

After spending some time looking for this, I stumbled upon this post , introducing the incomplete Mingw32 Alternate C Runtime Library . However, it is not ready for use, and the developer seems to have abandoned it. Link to the main page here .

Posting this answer here, hoping that it will be useful to people who will come in the future in the future.

0
source share

This does not answer the question "how to avoid binding to MSVCRT.DLL", but if you are here for the more general question "How to link statically with MinGW" ...:

Connect with gcc -static -static-libgcc -static-libstdc++ and you will not need libgcc_s_dw2-1.dll and libstdc++-6.dll

-2
source share

All Articles