在 Fedora 28 上构建 XFSTK 错误:/usr/bin/ld: 找不到 -lboost_program_options

在 Fedora 28 上构建 XFSTK 错误:/usr/bin/ld: 找不到 -lboost_program_options

我下载了 xfstk 源代码并构建了它。我安装了依赖项boost,例如libusb-devel等...但尽管我安装了boost,但我收到错误消息,例如下面的消息,报告boost未安装。

...some output code here

[  0%] Built target docs
[  1%] Built target xfstk-command-line
[  2%] Automatic MOC for target XfstkFactory
[  2%] Built target XfstkFactory_autogen
[ 39%] Built target XfstkFactory
[ 40%] Automatic MOC for target xfstk-dldr-api
[ 40%] Built target xfstk-dldr-api_autogen
[ 40%] Linking CXX shared library libxfstk-dldr-api.so
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/../../../libboost_program_options.so when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/../../../libboost_program_options.a when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //lib/libboost_program_options.so when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //lib/libboost_program_options.a when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //usr/lib/libboost_program_options.so when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //usr/lib/libboost_program_options.a when searching for -lboost_program_options
/usr/bin/ld: cannot find -lboost_program_options
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/../../../libboost_program_options.so when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/../../../libboost_program_options.a when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //lib/libboost_program_options.so when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //lib/libboost_program_options.a when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //usr/lib/libboost_program_options.so when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible //usr/lib/libboost_program_options.a when searching for -lboost_program_options
/usr/bin/ld: cannot find -lboost_program_options
collect2: error: ld returned 1 exit status
make[2]: *** [ancillary/configure/api/downloader-api/CMakeFiles/xfstk-dldr-api.dir/build.make:137: ancillary/configure/api/downloader-api/libxfstk-dldr-api.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:366: ancillary/configure/api/downloader-api/CMakeFiles/xfstk-dldr-api.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
[frogwine@leopardpro build]$ 

答案1

当您尝试在 Linux 发行版上构建软件时,通常有两条路径可供选择。

选项

  1. 依靠 Linux 发行版的包管理器来为您完成繁重的工作
  2. 将您的自编译库合并到 LD 的路径中,以便构建/配置工具能够识别它。
选项1

对于第一点,您可以boost使用发行版包管理器进行安装。我更熟悉 Redhat 发行版,对于这些发行版,您可以这样做:

$ sudo yum search boost | grep ^boost | head
yum search boost | grep ^boost | head -10
boost-atomic.i686 : Run-Time component of boost atomic library
boost-atomic.x86_64 : Run-Time component of boost atomic library
boost-chrono.i686 : Run-Time component of boost chrono library
boost-chrono.x86_64 : Run-Time component of boost chrono library
boost-context.i686 : Run-Time component of boost context switching library
boost-context.x86_64 : Run-Time component of boost context switching library
boost-date-time.i686 : Run-Time component of boost date-time library
boost-date-time.x86_64 : Run-Time component of boost date-time library
boost-devel.i686 : The Boost C++ headers and shared development libraries
boost-devel.x86_64 : The Boost C++ headers and shared development libraries

然后从此输出中安装您需要的任何内容:

$ sudo yum install -y boost boost-devel ....
选项2

对于第二点,我已经在 U&L 问答中对此进行了介绍,标题为:编译时链接 boost 库的困惑

相关内容