Mingw 生成错误:未定义对"__chkstk_ms"的引用

mingw building error: undefined reference to `__chkstk_ms'

本文关键字:chkstk 引用 ms 错误 未定义 Mingw      更新时间:2023-10-16

我刚刚在windows中安装了mingw,我编写了一个helloWorld程序来测试它。代码:

#include <stdio.h>
int main(){
    printf("hello, world!n");
    return 0;
}

结果:

C:/MinGW/lib/crt2.o:crt1.c:(.text+0x1f1): undefined reference to `__chkstk_ms'
C:/MinGW/lib/libmingwex.a(glob.o):glob.c:(.text+0x5e3): undefined reference to `__chkstk_ms'
C:/MinGW/lib/libmingwex.a(glob.o):glob.c:(.text+0x690): undefined reference to `__chkstk_ms'
C:/MinGW/lib/libmingwex.a(glob.o):glob.c:(.text+0x7e9): undefined reference to `__chkstk_ms'
C:/MinGW/lib/libmingwex.a(glob.o):glob.c:(.text+0x82d): undefined reference to `__chkstk_ms'
C:/MinGW/lib/libmingwex.a(glob.o):glob.c:(.text+0xc0d): more undefined references to `__chkstk_ms' follow

这里也提出了类似的问题。但我检查了MinGW安装管理器,似乎我没有安装旧版本的gcc或g++。有朋友帮忙吗?谢谢

顺便说一句,由于我使用pythonxy作为我的python环境,在我的C:下还有一个C:/MinGW32xy目录,它不包括在系统变量"path"中。这会影响吗?

好吧,我详细检查了我的系统变量,发现C:/MinGW32 xy/bin在C:/MinGW/bin之前。因此,当我在命令行中键入gcc-v时,它表明MinGW32 xy正在工作。我改变了他们的顺序,问题解决了。然而,我真的不知道MinGW和MinGW32xy之间的区别。有朋友能给我一个提示吗?

我使用mingw 4.7.1

我在E:\Portable Apps 中创建了一个文件名main.cpp

我的gcc位于C:\Program Files\CodeBlocks\MinGW\bin 中

我在cmd中键入这个(cmd=命令行),它对我来说很好:

e:
cdPortable Apps
"C:Program FilesCodeBlocksMinGWbingcc" -c "main.cpp"
"C:Program FilesCodeBlocksMinGWbingcc" "main.o" -o "hello 1.exe" -L"main.cpp"