Fedora

在 Fedora 28 上建構 XFSTK 錯誤:/usr/bin/ld: 找不到 -lboost_program_options

  • July 22, 2018

我下載了 xfstk 原始碼並建構了它。我安裝了依賴項,例如boostlibusb-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]$ 

當您嘗試在 Linux 發行版上建構軟體時,通常有 2 條路徑可供選擇。

選項

  1. 依靠 Linux 發行版的包管理器為您完成繁重的工作
  2. 將您自己編譯的庫合併到 LD 的路徑中,以便建構/配置工具知道它。

選項1 對於數字 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 對於第 2 點,我已經在此 U&L Q&A 中介紹了這一點,標題為:Confusion about linking boost library while compilation

引用自:https://unix.stackexchange.com/questions/453950