mingw building error: undefined reference to `__chkstk_ms'

冷暖自知 提交于 2021-02-08 19:29:42

问题


I've just installed mingw in windows, and I write a helloWorld program to test it. Code:

#include <stdio.h>

int main(){
    printf("hello, world!\n");
    return 0;
}

Result:

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

There is a similar question asked here. But I checked the MinGW installation manager and it seems taht I didn't install old version of gcc or g++. Can any buddy help? Thanks!

By the way, since I'm using pythonxy as my python environment, there is also a C:/MinGW32-xy directory under my C:, which is not included in the system variable 'path'. Would that affect?


回答1:


Well, I checked my system varialble in detail and found that the C:/MinGW32-xy/bin was before C:/MinGW/bin. So when I typed gcc -v in the command line, it shows that MinGW32-xy was at work. I switched their order, the problem was solved. However, I don't really know the difference between the MinGW and MinGW32-xy. Can any buddy give me a hint?




回答2:


i use mingw 4.7.1

i make a file name main.cpp in E:\Portable Apps

my gcc is in C:\Program Files\CodeBlocks\MinGW\bin

i type this in cmd (cmd = command line) and it work fine for me:

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"


来源:https://stackoverflow.com/questions/20135923/mingw-building-error-undefined-reference-to-chkstk-ms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!