【发布时间】:2017-03-27 16:43:38
【问题描述】:
我看到有人提出了类似的问题,但没有一致的解决方案。 在 linux 上使用 gcc 编译器,我得到消息:
/tmp/ccPNsJFZ.o: In function `main':
testChTh.c:(.text+0xbfb): undefined reference to `shm_open'
collect2: error: ld returned 1 exit status
在命令行中输入gcc -pthread -lrt -o testChTh testChTh.c 后。我在我的代码中只使用了一次 shm_open,即:
int shm_fd;
/* create the shared memory segment */
shm_fd = shm_open(name, O_RDWR, 0666);
我包含以下相关库:
#include <fcntl.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
非常感谢任何见解!
【问题讨论】: