Pages

pthread error: undefined reference to `pthread_create'





The above error is a common error encountered by a number of people who begin writing programs using pthreads. The POSIX libraries required for pthread functions are not linked by the compiler unless we don't ask or it to be linked. Thus we see the above error.

The simple workaround is to pass the option "-lp" to the compiler while compiling the code.
Example:



Now we should not get the above error.

No comments:

Post a Comment