|

楼主 |
发表于 2003-10-25 10:57:02
|
显示全部楼层
原程序是这样的
/*semacreate.c*/
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <semaphore.h>
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
int main(int argc, char **argv)
{
int c, flags;
sem_t *sem;
unsigned int value;
flags = O_RDWR | O_CREAT;
value = 1;
sem = sem_open("\\tmp\\my", flags, FILE_MODE, value);
sem_close(sem);
return (0);
}
编译成目标代码不会出错。gcc -c semacreate.c
但是连接成可执行文件 就出错
gcc semacreate.c -o semacreate
/tmp/cc4Wrbww.o: In function 'main':
/tmp/cc4Wrbww.o(.tex + 0xae):undefined reference to 'sem_open'
/tmp/cc4Wrbww.o(.tex + 0xbf):undefined reference to 'sem_close'
collect2:ld returned 1 exit status
这到底是怎么回事 哪位告诉我阿 |
|