How to solve -------undefined reference to `__chkstk_ms#39;-------on 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
基础教程推荐
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 从 std::cin 读取密码 2021-01-01