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;
}
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.
Related
I recently downloaded gcc and g++ compiler using MinGW and tried a simple hello world printing file in c. Whenever I run the code using visual studio code(using the code-runner extension made by jun han), I run into the following error:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(setargv.o):(.text+0x33): undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingwex.a(glob.o):(.text+0x6d2): undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingwex.a(glob.o):(.text+0x8b8): undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingwex.a(glob.o):(.text+0x900): undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingwex.a(glob.o):(.text+0xa25): undefined reference to `__chkstk_ms'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingwex.a(glob.o):(.text+0xc15): more undefined references to `__chkstk_ms' follow
collect2: ld returned 1 exit status
NOTE: I HAVE SEEN THE POST BY YUNUS
3.4.5, is that the version? That's very old!
Which MinGW were you using exactly?
I recommend using MinGW-w64 as it's more up to date.
You can get a standalone build from https://winlibs.com/
As for your errors, they are related to stack protection settings. Make sure you don't have different MinGW's in your system or referred to by environment variables like PATH.
add gcc path to you envionment variables
I'm trying to install AODV protocol on Raspberry pi. After completing git clone from "https://github.com/erimatnor/aodv-uu" when I tried to do "make" and I am getting below error. Expecting your suggestion. Thank you!
make
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY -DDEBUG -o aodvd main.o list.o debug.o timer_queue.o aodv_socket.o aodv_hello.o aodv_neighbor.o aodv_timeout.o routing_table.o seek_list.o aodv_rreq.o aodv_rrep.o aodv_rerr.o nl.o locality.o
aodv_neighbor.o: In function neighbor_add':
/home/pi/aodv-uu/aodv_neighbor.c:68: undefined reference tohello_update_timeout'
aodv_timeout.o: In function route_discovery_timeout':
/home/pi/aodv-uu/aodv_timeout.c:98: undefined reference tort_table_update_timeout'
aodv_rreq.o: In function rreq_route_discovery':
/home/pi/aodv-uu/aodv_rreq.c:460: undefined reference tort_table_update_timeout'
aodv_rreq.o: In function rreq_local_repair':
/home/pi/aodv-uu/aodv_rreq.c:521: undefined reference tort_table_update_timeout'
aodv_rrep.o: In function rrep_forward':
/home/pi/aodv-uu/aodv_rrep.c:231: undefined reference tort_table_update_timeout'
nl.o: In function nl_kaodv_callback':
/home/pi/aodv-uu/nl.c:282: undefined reference tort_table_update_timeout'
collect2: error: ld returned 1 exit status
Makefile:112: recipe for target 'aodvd' failed
make: *** [aodvd] Error 1
The code available from sourceforge is the same code that is on github. If you download the archive, you'll see that the latest modification date of any file there is 2010. Given the age of this code, I wouldn't be surprised to find that things simply don't work anymore.
However, here's a quick workaround for your problem. The root cause appears to be that the problem functions, like rt_table_update_timeout, are declared as inline, but that information seems to get lost somewhere in the build process such that other object files are trying to reference these as non-inline functions.
You can avoid this by opening defs.h, looking for this line:
#define NS_INLINE inline
And replace it with:
#define NS_INLINE
This will allow aodvd to compile correctly (make aodvd). On my system, the kernel module will subsequently fail to compile:
cc1: fatal error: /lib/modules/4.13.15-100.fc25.x86_64/build/include/linux/modversions.h: No such file or directory
As far as I can tell, the modversions.h file is no longer produced by modern Linux kernels.
I'm using the Eclipse Oxygen IDE on Linux, and I am trying to code in C. There are some problems though.
Whatever code I try to build, even perfectly valid code, returns this error:
make all
Building target: heyson
Invoking: GCC C Linker
gcc -o "heyson" ./heyson.o
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
makefile:29: recipe for target 'heyson' failed
collect2: error: ld returned 1 exit status
make: *** [heyson] Error 1
This is all of my code:
#include <stdio.h>
int main(){
printf("hello");
return 0;
}
It's literally a hello-world program. I tried putting main(void), but that returned the same error, I tried removing the #include line but that kept it the same, I did nigh everything possible to this and it keeps spitting out the same thing.
All I did, was install the C/C++ version of eclipse, use the Linux GCC toolchain to create a project, create a source file called heyson.c, and put this code in, trying to build it. After some time I realised that everything I put in returned the same thing, so I'm at the point of desperation...
UPDATE: I decided to uninstall Eclipse and use CLion instead. It works brilliantly, so I can only conclude that the problem was the IDE itself.
So I've just got a brand new laptop (Windows 10) and have been installing everything I need.
I downloaded MinGW and installed gcc, added it the PATH etc. I thought I would compile a completely standard, basic HelloWorld C program just to check that it works. (This file has been copied straight across from my old laptop where it compiles perfectly). This is what I got:
C:\...\Documents\C>gcc prog1.c -o prog1
/mingw/lib/libmingw32.a(setargv.o):(.text+0x30): undefined reference to `__chkstk_ms'
/mingw/lib/libmingwex.a(glob.o):(.text+0x673): undefined reference to `__chkstk_ms'
/mingw/lib/libmingwex.a(glob.o):(.text+0x7e0): undefined reference to `__chkstk_ms'
/mingw/lib/libmingwex.a(glob.o):(.text+0x81d): undefined reference to `__chkstk_ms'
/mingw/lib/libmingwex.a(glob.o):(.text+0x934): undefined reference to `__chkstk_ms'
/mingw/lib/libmingwex.a(glob.o):(.text+0xb78): more undefined references to `__chkstk_ms' follow
collect2: ld returned 1 exit status
Previous questions similar to this have been the result of version conflicts, which, as far as I can tell, I don't have. And since the laptop is brand new I don't have any previously installed things that I've forgotten about which could be conflicting.
Any help on fixing this would be much appreciated.
I'm getting a linker error whenever I #include in my program. I have downloaded libcurl from haxx.se, compiled libcurl.dll, and added -Icurl to my GCC options when compiling (as well as tried adding a direct path using -L to the dll). However, I still get the following errors:
undefined reference to `_imp__curl_easy_init'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_perform'
undefined reference to `_imp__curl_easy_strerror'
undefined reference to `_imp__curl_easy_cleanup'
My compile command includes this:
-Icurl -L"F:/GCCnew/lib/libcurl.dll"
What am I doing wrong? I suspect it's something simple but I can't work it out and searching hasn't given me a solution that doesn't use something like Code::blocks.
My compile command includes this:
-Icurl -L"F:/GCCnew/lib/libcurl.dll"
If you use mingw gcc, then:
First, -L must have a folder name, not a library name.
Second, there must be '-l' option. For example -lcurl.
Third, -Icurl is irrelevant to your linker error
So the command to build might look like:
gcc your-file.c -o executable_name -L"F:/GCCnew/lib" -lcurl
Useful links:
http://www.mingw.org/wiki/sampleDLL (Building a client executable)
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use
http://www.mingw.org/wiki/LibraryPathHOWTO