undefined reference to `shm_unlink'

1、问题描述:

在编译一个程序的时候提示这样的错误:

BLog.cpp:(.text+0x5fc): undefined reference to `shm_unlink‘
DBLog.cpp:(.text+0x610): undefined reference to `shm_open‘
/home/SCS/install/lib/liblog4cplus.a(timehelper.o): In function `log4cplus::helpers::Time::gettimeofday()‘:
/mnt/hgfs/07svn/program/SDK/log4plus/log4cplus-1.1.0/log4cplus-1.1.0/src/timehelper.cxx:102: undefined reference to `clock_gettime‘
/home/SCS/install/lib/liblog4cplus.a(sleep.o): In function `unix_nanosleep‘:
/mnt/hgfs/07svn/program/SDK/log4plus/log4cplus-1.1.0/log4cplus-1.1.0/src/sleep.cxx:52: undefined reference to `clock_nanosleep‘
collect2: ld 返回 1

2、解决办法

在前面编译的时候还没出错,只是将原来链接的liblog4cplus.so改为liblog4cplus.a,然后编译就出错了,网上搜了一下在需要加上-lrt选项,编译通过了。

3、-lrt

http://www.lehman.cuny.edu/cgi-bin/man-cgi?librt+3

rt库是运行时库,提供了一些额外的函数定义。

undefined reference to `shm_unlink'

时间: 2024-08-23 23:03:02

undefined reference to `shm_unlink'的相关文章

gcc/g++ undefined reference to function() 问题的解决方法

g++ 编译一个程序g++ shm.c -o shm, 用到了 shm_open(), shm_unlink()函数,编译出现了下面的错误: /tmp/ccL2cbha.o: In function `del_resource()': shm.c:(.text+0x1b3): undefined reference to `shm_unlink' /tmp/ccL2cbha.o: In function `main': shm.c:(.text+0x872): undefined referen

caffe日常坑系列之:undefined reference to symbol '_ZN2cv6String10deallocateEv'

在使用caffe库编译C++时出现的 解决如下: /usr/bin/ld: /tmp/ccA5JGRP.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'//usr/local/lib/libopencv_core.so.3.2: error adding symbols: DSO missing from command line解决:sudo apt-get autoremove libopencv-dev caffe

在codeblocks 下,C++编译不成功一直出现“undefined reference to `std::cout'|

自己搞了好久才知道,编辑c++,要用g++ 希望对大家有帮助 在codeblocks 下,C++编译不成功一直出现"undefined reference to `std::cout'|

Linux下运行《UNIX环境高级编程》undefined reference to `err_quit 编译出错的处理方法

错误信息: : undefined reference to `err_quit': undefined reference to `err_sys' 解决方法: 因为err_quit跟err_sys是作者自己定义的错误处理函数.所以最简单的解决办法是修改下apue.h文件,如下 /* * Our own header, to be included before all standard system headers. */ #ifndef _APUE_H #define _APUE_H #d

lua-5.2.3编译问题记录"libreadline.so: undefined reference to `PC'"

作者:zhanhailiang 日期:2014-10-21 [root@~/software]# cd lua-5.2.3 [root@~/software/lua-5.2.3]# make linux cd src && make linux make[1]: Entering directory `/root/software/lua-5.2.3/src' make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,

编译busybox遇到mount.c:(.text.nfsmount+0x): undefined reference to

如下: mount.c:(.text.nfsmount+0xa68): undefined reference to `authunix_create_default' mount.c:(.text.nfsmount+0xaeb): undefined reference to `clnt_sperror' mount.c:(.text.nfsmount+0xb12): undefined reference to `clnt_sperror' mount.c:(.text.nfsmount+0

undefined reference to `sin'问题解决

作者:zhanhailiang 日期:2014-10-25 使用gcc编译例如以下代码时报"undefined reference to `sin'": #include <stdio.h> #include <math.h> #include <stdlib.h>   main () { double a = sin(1); exit (0); } [root@~/wade/codeReview/learningc/9]# gcc -o timet

Linux下编译程序时,经常会遇到“undefined reference to XXX” 报错,

Linux下编译程序时,经常会遇到“undefined reference to XXX” 报错, 这里总结一些可能的原因和解决方案,给需要的朋友: 说道undefined reference error,先提一下Linux gcc链接规则: 链接的时候查找顺序是: -L 指定的路径, 从左到右依次查找 由 环境变量 LIBRARY_PATH 指定的路径,使用":"分割从左到右依次查找 /etc/ld.so.conf 指定的路径顺序 /lib 和 /usr/lib (64位下是/lib

undefined reference to `__sync_bool_compare_and_swap_4

然后开始glibc的编译工作. 你必须设定march这个参数才行,要不然会出现“undefined reference to `__sync_bool_compare_and_swap_4′.”这个错误 Core 2 Duo, GCC 4.2,CFLAGS 添加 -march=nocona -mtune=generic. 如果是GCC 4.1,Core Solo/Duo使用-march=prescott: Core 2 Duo/Solo则使用-march=nocona. i686等类似设置,例如