美文网首页
warning: librt.so.1, needed by .

warning: librt.so.1, needed by .

作者: 心惊梦醒 | 来源:发表于2022-06-14 10:38 被阅读0次

    gcc命令:

    g++ xx.o xy.o -o xx -fPIC -O3  -std=c++0x `python3-config --includes` -I`readlink -f ..` -I ./anaconda3.8.3/include -DGADABIN -lm -lboost_program_options -lboost_iostreams -L ./anaconda3.8.3/lib
    

    编译报错:

    ld: warning: librt.so.1, needed by ./anaconda3.8.3/lib/libboost_program_options.so, not found (try using -rpath or -rpath-link)
    ld: warning: libpthread.so.0, needed by ./anaconda3.8.3/lib/libboost_iostreams.so, not found (try using -rpath or -rpath-link)
    ld: ./anaconda3.8.3/lib/./liblzma.so.5: undefined reference to `pthread_condattr_setclock@GLIBC_2.3.3'
    ld: ./anaconda3.8.3/lib/./libzstd.so.1: undefined reference to `pthread_join@GLIBC_2.2.5'
    ld: ./anaconda3.8.3/lib/./liblzma.so.5: undefined reference to `clock_gettime@GLIBC_2.2.5'
    ld: ./anaconda3.8.3/lib/./liblzma.so.5: undefined reference to `pthread_sigmask@GLIBC_2.2.5'
    ld: ./anaconda3.8.3/lib/./libzstd.so.1: undefined reference to `pthread_create@GLIBC_2.2.5'
    

    解决方法:
    在编译命令中加上-lpthread -lbrt,即:

    g++ xx.o xy.o -o xx -fPIC -O3  -std=c++0x `python3-config --includes` -I`readlink -f ..` -I ./anaconda3.8.3/include -DGADABIN -lm -lboost_program_options -lboost_iostreams -lpthread -lbrt -L ./anaconda3.8.3/lib
    

    参考:

    1. boost多线程undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5' - 简书 (jianshu.com)

    2. undefined reference to symbol 'pthread_condattr_setclock_吐鲁番木盆地的一块石头的博客-CSDN博客

    3. undefined reference to `clock_gettime' 链接错误的解决思路_码之有道的博客-CSDN博客

    相关文章

      网友评论

          本文标题:warning: librt.so.1, needed by .

          本文链接:https://www.haomeiwen.com/subject/wmfzmrtx.html