【发布时间】:2011-06-22 11:01:41
【问题描述】:
所以我收到错误:“未定义对 sem_open() 的引用”,即使我已经包含了 semaphore.h 标头。我所有的 pthread 函数调用(mutex、pthread_create 等)都发生了同样的事情。有什么想法吗?我正在使用以下命令进行编译:
g++ '/home/robin/Desktop/main.cpp' -o '/home/robin/Desktop/main.out'
#include <iostream>
using namespace std;
#include <pthread.h>
#include <semaphore.h>
#include <fcntl.h>
const char *serverControl = "/serverControl";
sem_t* semID;
int main ( int argc, char *argv[] )
{
//create semaphore used to control servers
semID = sem_open(serverControl,O_CREAT,O_RDWR,0);
return 0;
}
【问题讨论】: