How to link with msvcr90.dll with mingw gcc?

How to link with msvcr90.dll with mingw gcc? I tried -lmsvcr90, here is a minimal example:

#include <stdio.h> int main(int argc, const char *argv[]) { printf("%s\n", "hello"); return 0; } 

My OS is win7, with mingw gcc 4.5.0

 $ gcc -v ... gcc version 4.5.0 (GCC) $ gcc hello.c -lmsvcr90 $ a 

Then I got this error:

R6034

  An application has made an attempt to load the C runtime library incorrectly.
     Please contact the application support team for more information.

Which part am I missing?

edit1:

@ user440813 It seems my mingw is very different from yours.

 $ gcc hc -nostdlib -lmsvcr70 -lgcc -o h.exe d:/mingw/bin/../lib/gcc/mingw32/4.5.0/libgcc.a(__main.o):(.text+0x5a): undefined reference to `atexit' d:/mingw/bin/../lib/gcc/mingw32/4.5.0/libgcc.a(__main.o):(.text+0xc2): undefined reference to `atexit' collect2: ld returned 1 exit status 

Then I made fun of int atexit ( void ( * function ) (void) ) {return 0;} and again got R6034 ...

+5
source share
1 answer

Try

 gcc hello.c -nostdlib -lmsvcr90 -lgcc -o hello.exe 

instead of this. I'm a little surprised that your initial compilation attempt was successful, since conflicting definitions must exist between msvcr90 and msvcrt (default MinGW links by default). Thus, msvr90 connected, conflicting msvcrt does not work, but libgcc added to initialize the runtime library.

I do not have msvcr90.dll on my computer, but I was able to verify that a similar call works with msvcr100.dll .

+4
source

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


All Articles