【问题标题】:Linking boost_system when configured with apt-get install?使用 apt-get install 配置时链接 boost_system?
【发布时间】:2019-09-19 09:13:06
【问题描述】:

已安装 Cevelop 1.11.1

apt-get install g++-9
Get:1 http://archive.ubuntu.com/ubuntu disco/main amd64 cpp-9 amd64 9-20190402-1ubuntu1 [8,861 kB]
Get:2 http://archive.ubuntu.com/ubuntu disco/main amd64 libgcc-9-dev amd64 9-20190402-1ubuntu1 [2,355 kB]               
Get:3 http://archive.ubuntu.com/ubuntu disco/main amd64 gcc-9 amd64 9-20190402-1ubuntu1 [9,643 kB]                      
Get:4 http://archive.ubuntu.com/ubuntu disco/main amd64 libstdc++-9-dev amd64 9-20190402-1ubuntu1 [1,685 kB]            
Get:5 http://archive.ubuntu.com/ubuntu disco/universe amd64 g++-9 amd64 9-20190402-1ubuntu1 [10.1 MB]   

apt-get install libboost-dev
Get:1 http://archive.ubuntu.com/ubuntu disco/main amd64 libboost1.67-dev amd64 1.67.0-13 [8,362 kB]
Get:2 http://archive.ubuntu.com/ubuntu disco/main amd64 libboost-dev amd64 1.67.0.1 [3,228 B]                            

为链接器指定 boost_system。这会产生错误。

g++-9 -std=c++1z -O0 -g3 -Wall -Wextra -Wconversion -c -fmessage-length=0 -Wno-attributes -fsanitize=undefined -pthread -o aptcp.o ../aptcp.cpp 
g++-9 -pthread -o aptcp aptcp.o -ltidy -lboost_system -lssl -lcrypto -lxalan-c -lxalanMsg -lxerces-c 
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status

sмurf states in his answer:

我建议安装软件包 libboost-dev。它将安装 无论您的系统当前版本的 boost 是什么,都会放 所有文件都在适当的位置。

根据serup's answer,我的理解是“已安装库”。

$ /sbin/ldconfig -p | grep boost_system | cut -d\> -f2
 /lib/x86_64-linux-gnu/libboost_system.so.1.67.0

那么,这里发生了什么?

目标是为安装和使用编译器和库提供一个简单的可重复过程,该过程建立在开发人员和包维护者的现有工作之上。我的理解/期望、包装或库是否存在缺陷?

【问题讨论】:

    标签: linux boost configuration linker-errors apt


    【解决方案1】:
    sudo apt-get install libboost-all-dev
    

    这为我在 Ubuntu 19.04 上安装了所有必需的符号链接和静态库

    【讨论】:

      【解决方案2】:

      -l 选项只会找到 .a 或 .so 库文件,它不会找到 .so.1.67.0 或其他。 这可以通过创建符号链接来解决:

      ln -sf /your/path/to/libboost_system.so.1.67.0 /your/path/to/libboost_system.so
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-06-02
        • 2011-09-23
        • 1970-01-01
        • 2017-01-13
        • 2014-02-17
        • 2014-02-16
        • 1970-01-01
        相关资源
        最近更新 更多