c – 如何解决——-未明确引用`__chkstk_ms’——- on mingw

我刚刚在mingw上安装了gcc和g.
我写了一个非常简单的“hello world”程序来测试g编译器是否有效.
码:

#include <iostream>
using namespace std;
int main()
{
cout << "hello world" << endl;
return 0;
}

编译:

g++ Test.cpp

然后出现一些错误:

D:/MinGW[Finished in 0.6s with exit code    1]/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/crt2.o: In function `_mingw_setargv':
D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_match':
i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:733: undefined reference to `__chkstk_ms'
D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_strdup':
i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:85: undefined reference to `__chkstk_ms'
D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_match':
i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:841: undefined reference to `__chkstk_ms'
D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_strdup':
i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:85: undefined reference to `__chkstk_ms'
D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o):i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:85: more undefined references to `__chkstk_ms' follow
collect2: ld returned 1 exit status

解决方法:

关于链接旧库的原始问题似乎已经解决了,但我有相反的情况.
我需要使用较旧的GCC 3.4版本,所以我安装了gcc-v3-core软件包.
然后在链接一个普通的源时立即出现orig错误.
我发现MinGW GCC 3.4无法使用mingwrt> 3.20问题是gcc-v3-core包含不正确的mingwrt规范,允许最新的版本.

解决方案很简单:

mingw-get upgrade "mingwrt=3.20.*"

!更新!
实际上,使用mingwrt-3.20链接器报告C代码的相同错误:

g++ hello.cpp

BAM!

解决方案2:

mingw-get upgrade "mingwrt=3.18.*"

最后一个似乎与gcc-v3-g一起使用.

上一篇:C语言I博客作业02


下一篇:C语言|博客作业02