2010-08-04 18 views
5

Cómo vincularse con msvcr90.dll con mingw gcc? Probé -lmsvcr90, aquí está el ejemplo mínimo:Cómo vincularse con msvcr90.dll con mingw gcc?

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

Mi sistema operativo es win7, con gcc MinGW 4.5.0

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

Entonces me dio este mensaje:

R6034

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

¿Qué parte me estoy perdiendo?

edit1:

@ user440813 Parece que mi MinGW es muy diferente a la suya.

$ gcc h.c -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 

Entonces se burlaban int atexit (void (* function) (void)) {return 0;} y tiene R6034 nuevo ...

Respuesta

4

Trate

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

lugar. Estoy un poco sorprendido de que tu intento de compilación original haya tenido éxito, ya que debería haber definiciones conflictivas entre msvcr90 y msvcrt (que MinGW enlaza por defecto). De esta forma, msvr90 se vincula, la conflictiva msvcrt no, pero se agrega libgcc para inicializar la biblioteca de tiempo de ejecución. No tengo msvcr90.dll en mi computadora, pero pude verificar que la invocación análoga funciona con msvcr100.dll.

Cuestiones relacionadas