Reputation: 9
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.
Upvotes: 0
Views: 135
Reputation: 10430
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.
Upvotes: 0
Reputation: 4525
Are you sure you remembered the -lpthread flag in compilation? Usually that's the source of this error.
Upvotes: 6