tags:

views:

79

answers:

2

On compiling I am getting an error "undefined reference to pthread_create()" and similarly for "undefined reference to pthread_join()". What are the possible reasons? I am unable to identify them.

+6  A: 

Are you sure you remembered the -lpthread flag in compilation? Usually that's the source of this error.

Spencer Nelson
+1 Most probable reason.
karlphillip
A: 

You should add -pthread, which adds the required flags for the preprocessor as well as the linker. The flag suggested by others, -lpthread, only links the library, which may lead to the system libraries not having proper threading support.

Tronic