I am new to posix thread library and I tried to compile sample code from a tutorial using
g++ -lpthread agreement.cpp -o agreement
however, I could not compile the code and received the following error message:
a3q2.cpp:(.text+0x7e): undefined reference to `sem_open'
a3q2.cpp:(.text+0xab): undefined reference to `sem_wait'
a3q2.cpp:(.text+0x290): undefined reference to `sem_post'
a3q2.cpp:(.text+0x2af): undefined reference to `sem_close'
a3q2.cpp:(.text+0x2bb): undefined reference to `sem_unlink'
collect2: ld returned 1 exit status
make: *** [a3q2_exe] Error 1
I know that you need to use -lpthread to compile, but are there any other options that may arise to solve the problem? if not, how can I install the "correct" pthread library?
Thank you for your help!
source
share