如何使用 mingw gcc 链接 msvcr90.dll?

2024-05-27

如何使用 mingw gcc 链接 msvcr90.dll?我尝试了 -lmsvcr90,这是最小的示例:

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

我的操作系统是win7,使用mingw gcc 4.5.0

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

然后我得到这个错误:

R6034



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

我缺少哪一部分?

edit1:

@user440813 看来我的 mingw 和你的很不一样。

$ 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

然后我就嘲笑了int atexit ( void ( * function ) (void) ) {return 0;}并得到了R6034再次 ...


Try

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

反而。我对您最初的编译尝试成功感到有点惊讶,因为之间应该存在冲突的定义msvcr90 and msvcrt(MinGW 默认链接)。这边走,msvr90相互联系,相互冲突msvcrt不,但是libgcc添加以初始化运行时库。

我没有msvcr90.dll在我的计算机上,但我能够验证类似的调用是否适用于msvcr100.dll.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 mingw gcc 链接 msvcr90.dll? 的相关文章

随机推荐