zoukankan      html  css  js  c++  java
  • 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库是运行时库,提供了一些额外的函数定义。

  • 相关阅读:
    Java并发学习笔记
    OSI七层网络模型
    网络寻址过程
    ThinkPhp之Rce分析
    Java cc6
    Java cc1
    Yso中的URLDNS分析学习
    JWT攻防
    权限维持之创建本地账号(T1136.001)
    redis配置修改后不生效的原因
  • 原文地址:https://www.cnblogs.com/lit10050528/p/4166351.html
Copyright © 2011-2022 走看看