I have this code:
#include
#include
void* cuoco(void* arg)
{
fprintf(stderr,\"Inizio codice cuoco\\n\");
fprintf(s
In Eclipse, you should add string pthread.
Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> GCC Linker -> Libraries -> Libraries (-l) -> Add -> pthread
After this, you can Build your project.
Use the following command:
gcc -pthread -o main main.c
Without seeing the compiler command, I suspect -lpthread
is not at end. Libraries need to be placed at end of the compiler command:
gcc main.c -lpthread
However, use -pthread
instead of -lpthread
, as -pthread
may add other settings (like defining the macro _REENTRANT
for example).
found the solution guys :D
just go to settings >> compiler >> linker tab >>add lib
go to drive and go to lib folder and find x86_64_linux_gnu
and find pthread
enjoy :)
Use -lpthread as the last compiler flag.
example:
gcc -o sample sample.c -lpthread