编译出错:
对‘shm_open’未定义的引用
原因:
一般出错的原因是没有链接库导致的
解决方法:
在编译最后添加 -lrt
例如:
gcc -o test test.c -lrt
man shm_open的帮助文件的最后几行:
NOTES
These functions are provided in glibc 2.2 and later. Programs using
these functions must specify the -lrt flag to cc in order to link
against the required ("realtime") library.
本文详细解析了在使用shm_open函数时遇到的编译错误原因,并提供了有效的解决方案。通过在编译命令中添加-lrt参数,可以成功链接到实时库,解决未定义的引用错误。
1662

被折叠的 条评论
为什么被折叠?



