Unable to play:
#include <pthread.h>
void *thread(void *arg)
{
(void) arg;
return 0;
}
int main(void)
{
pthread_t t;
pthread_create(&t, 0, thread, 0);
return 0;
}
Attempting to link without libpthread
:
> gcc -Wall -o thread thread.c
/tmp/ccyyu0cn.o: In function `main':
thread.c:(.text+0x2e): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
edit : you can check the characters defined in the library with nm -D
, for example. in my case:
> nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep pthread_create
> nm -D /lib/x86_64-linux-gnu/libpthread.so.0 | grep pthread_create
00000000000082e0 T pthread_create
(therefore pthread_create
not found in libc
, but valid in libpthread
)
edit2: , , , , (libc
, libgcc
), pthread_create
. , , , libpthread
. , . , .