如何解决-------未定义的引用`__chkstk_ms'-------关于mingw

How to solve -------undefined reference to `__chkstk_ms#39;-------on mingw(如何解决-------未定义的引用`__chkstk_ms-------关于mingw)

本文介绍了如何解决-------未定义的引用`__chkstk_ms'-------关于mingw的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 mingw 上安装了 gcc 和 g++.我编写了一个非常简单的hello world"程序来测试 g++ 编译器是否工作.代码:

I have just install gcc and g++ on mingw. I wrote a very simple "hello world" program to test if the g++ compiler worked. Code:

#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:pgiawsrcpkgmingwrt-4.0-1-mingw32-srcld/../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:pgiawsrcpkgmingwrt-4.0-1-mingw32-srcld/../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:pgiawsrcpkgmingwrt-4.0-1-mingw32-srcld/../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:pgiawsrcpkgmingwrt-4.0-1-mingw32-srcld/../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:pgiawsrcpkgmingwrt-4.0-1-mingw32-srcld/../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 包.然后在链接一个琐碎的源时立即出现原始错误.我发现 MinGW GCC 3.4 不能与 mingwrt > 3.20 一起使用,问题是 gcc-v3-core 包含不正确的 mingwrt 规范,允许使用最新版本.

The orig problem seems solved regarding linking against old libs, but I have opposite case. I need to work with older GCC 3.4 version, so I installed gcc-v3-core package. Then orig errors immediately appear when linking a trivial source. I found out that MinGW GCC 3.4 cannot work with mingwrt > 3.20 and the problem is that gcc-v3-core contains incorrect mingwrt spec, allowing newest vesions.

解决方法很简单:

mingw-get upgrade "mingwrt=3.20.*"

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

!Update! Actually with mingwrt-3.20 linker reports same errors for C++ code:

g++ hello.cpp

砰!

解决方案 2:

mingw-get upgrade "mingwrt=3.18.*"

最后一个似乎与 gcc-v3-g++ 一起工作的.

the last one that seems to work with gcc-v3-g++.

这篇关于如何解决-------未定义的引用`__chkstk_ms'-------关于mingw的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何解决-------未定义的引用`__chkstk_ms'-------关于mingw

基础教程推荐