本文介绍了如何使用mingw gcc链接msvcr90.dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用mingw gcc链接msvcr90.dll?我试过-lmsvcr90,这里是最简单的例子:

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

我的操作系统是win7,带有mingw gcc 4.5.0

  $ gcc -v 
...
gcc版本4.5.0(GCC)
$ gcc hello。 c -lmsvcr90
$ a

然后我得到这个错误:



R6034

 
应用程序尝试错误地加载C运行时库。
请联系应用程序的支持团队获取更多信息。


我缺少哪一部分?

edit1:



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

  $ gcc hc -nostdlib -lmsvcr70 -lgcc -o h.exe 
d:/ mingw / bin /../ lib / gcc / mingw32 / 4.5.0 / libgcc.a(__ main.o):( .text + 0x5a ):对`atexit'的未定义引用
d:/ mingw / bin /../ lib / gcc / mingw32 / 4.5.0 / libgcc.a(__ main.o):( .text + 0xc2):undefined reference to `atexit'
collect2:ld返回1退出状态

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

试试

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

改为。我有点惊讶你原来的编译尝试成功了,因为在 msvcr90 msvcrt (MinGW默认链接)。通过这种方式, msvr90 被链接,冲突的 msvcrt 不会,但是 libgcc 被添加以初始化运行时库。



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


How to link against msvcr90.dll with mingw gcc? I tried -lmsvcr90, here's the 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's support team for more information.

Which part am I missing ?

edit1:

@user440813 Seems my mingw is very different from yours.

$ 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

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

解决方案

Try

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

instead. I'm a little surprised that your original compilation attempt succeeded, since there should've been conflicting definitions between msvcr90 and msvcrt (which MinGW links in by default). This way, msvr90 gets linked in, the conflicting msvcrt doesn't, but libgcc gets added in order to initialize the runtime library.

I don't have msvcr90.dll on my computer, but I was able to verify that the analogous invocation works with msvcr100.dll.

这篇关于如何使用mingw gcc链接msvcr90.dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 19:53