#include <semaphore.h>
sem_t mutex;
int main (int argc, char * argv[])
{
sem_init (&mutex,0,1);
}
我得到了:
/tmp/ccAMFxDX.o: In function `main':
programaservidor.c:(.text+0x86): undefined reference to `sem_init'
collect2: ld returned 1 exit status
发布于 2010-12-01 01:14:25
根据sem_init()手册页
使用-lrt或-pthread的
链接。
与gcc your_code.c -lpthread -o your_code
中的一样
发布于 2010-12-01 01:15:07
如手册页所述,您必须使用-lrt
或-pthread
进行链接。
发布于 2010-12-01 01:28:53
相关的POSIX参考是:
http://www.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_13
https://stackoverflow.com/questions/4316460
复制相似问题