mingw构建错误:未定义引用`__chkstk_ms'

时间:2013-11-22 02:32:17

标签: c++ windows gcc mingw

我刚刚在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

有一个类似的问题here。但我检查了MinGW安装管理器,似乎我没有安装旧版本的gcc或g ++。任何好友都可以帮忙吗?谢谢!

顺便说一句,因为我使用pythonxy作为我的python环境,所以在我的C:下还有一个C:/ MinGW32-xy目录,它不包含在系统变量'path'中。那会有影响吗?

2 个答案:

答案 0 :(得分:2)

好吧,我详细检查了我的系统varialble,发现C:/ MinGW32-xy / bin在C:/ MinGW / bin之前。因此,当我在命令行中键入gcc -v时,它显示MinGW32-xy正在运行。我改变了他们的订单,问题解决了。 但是,我真的不知道MinGW和MinGW32-xy之间的区别。任何哥们都能给我一个暗示吗?

答案 1 :(得分:0)

我使用mingw 4.7.1

我在E:\ Portable Apps

中创建一个文件名main.cpp

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

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

e:
cd\Portable Apps
"C:\Program Files\CodeBlocks\MinGW\bin\gcc" -c "main.cpp"
"C:\Program Files\CodeBlocks\MinGW\bin\gcc" "main.o" -o "hello 1.exe" -L"main.cpp"
相关问题