2
私は一貫した解決策がないと同様の質問が出されているのを見ています。コマンドラインにgcc -pthread -lrt -o testChTh testChTh.c
を入力した後-pthread -lrtでコンパイルしていても `shm_open 'への未定義の参照
/tmp/ccPNsJFZ.o: In function `main':
testChTh.c:(.text+0xbfb): undefined reference to `shm_open'
collect2: error: ld returned 1 exit status
:Linux上のgccコンパイラを使用して 、私はメッセージを取得します。私は以下の関連のライブラリが含まれている
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>
私だけで私のコードに一度のshm_open使用します!あなたがlibrt
を使用することを期待し、最後にtestChTh.c
を提供しているとして、あなたの場合は
ありがとうございます、これはうまくいきました。 –