I am writing a program in C. I am getting the error:
file_name.c:(.text+0x5d): undefined reference to `pthread_create'
This specific error comes up when gcc is linking my file_name.o with my main ADA file.
For the actual compilation of the C file, I have tried using both:
gcc -c -pthread file_name.c
as well as:
gcc -c file_name.c -lpthread
Neither of these seem to work. Any thoughts?
UPDATE:
One thing I did not realize is that when combining C and ADA, the C libraries are included when using gnatmake.
The problem was solved by using:
gnatmake ada_file.adb -o -largs c_file.o -lpthread
gcc -cdoes compiling but no linking. What command are you using to link, where the actual error occurs? - ascheplergnatmake. The actual linking part is done using the gnatmake flag-largsthat is followed byfile_name.o- Nautilusgnatmakefacility — it isn't linking what you need to link. Suggesting that GCC is at fault seems like it might be misdirecting the blame. - Jonathan Lefflergnatmakethe Gnat linker process? If so, you might need to add-lpthreadafter thec_file_name.oargument. Or you might need to RTFM ongnatmake. Does Gnat allow you to mix Ada threads with POSIX threads? - Jonathan Leffler