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.
views:
79answers:
2
+6
A:
Are you sure you remembered the -lpthread flag in compilation? Usually that's the source of this error.
Spencer Nelson
2010-08-20 23:59:03
+1 Most probable reason.
karlphillip
2010-08-21 00:02:22
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
2010-08-21 00:04:03