Youri_Miner
Youri_Miner

Reputation: 13

MingGw error while trying to complie C code

I tried to compile my C code (using mingw) into a EXE file but it just says the following error:

/mingw/lib/libmingw32.a(setargv.o):(.text+0x33): undefined reference to `__chkstk_ms' /mingw/lib/libmingwex.a(glob.o):(.text+0x6d2): undefined reference to `__chkstk_ms' /mingw/lib/libmingwex.a(glob.o):(.text+0x8b8): undefined reference to `__chkstk_ms' /mingw/lib/libmingwex.a(glob.o):(.text+0x900): undefined reference to `__chkstk_ms' /mingw/lib/libmingwex.a(glob.o):(.text+0xa25): undefined reference to `__chkstk_ms' /mingw/lib/libmingwex.a(glob.o):(.text+0xc15): more undefined references to `__chkstk_ms' follow collect2: ld returned 1 exit status

i ran the command

mingw-get upgrade "mingwer=3.20.*"

and

mingw-get upgrade "mingwer=3.18.*"

but didn't solve the issue

Edit: Command ran

gcc compvisia.c init.c bitboards.c hashkeys.c board.c -o compvisia

Code:

#include "stdio.h"
#include "stdlib.h"

int main() {
   printf("hello world");
   return 0;
}

Upvotes: 0

Views: 237

Answers (1)

Brecht Sanders
Brecht Sanders

Reputation: 7287

Looks like the errors are related to stack protection.

Maybe your system has a mix of different MinGW versions installed, causing linking with mismatching libraries.

MinGW 3 is old, you should really consider moving to MinGW-w64.

You can get a standalone build of MinGW-w64 from https://winlibs.com/ that you can extract somewhere without installing to test if it makes a difference for your source code.

Make sure to use the full path to gcc.exe so you are in fact using the one you think you are using.

Upvotes: 1

Related Questions