I am writing a program in C. I am getting the error:
file_name.c:(.text+0x5d): undefined reference to `pthread_create'
gcc -c -pthread file_name.c
gcc -c file_name.c -lpthread
gnatmake ada_file.adb -o -largs c_file.o -lpthread
If you are using
-c switch, you are not linking your code. You are simply compiling it into object files. There's no point in specifying the libraries at this stage. Your
-l parameter is simply ignored - it has no effect and no meaningful purpose when
-c is present.
The libraries are supposed to be supplied at the moment of linking, i.e. at the moment when you combine your object files into the final executable (without
-c, of course). You are not showing us that command line. That linking line is exactly where you have to add your