为什么CMake在Ubuntu 18.04上找不到我的Boost库?

乔兹林

这让我发疯。在我的CMakeLists.txt我有:

find_package(Boost 1.63.0 REQUIRED SYSTEM)

结果:


[0/1] Re-running CMake...
Build type: Release
CMake Error at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1947 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.1

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_system

但:

$ locate libboost_system
/usr/lib/x86_64-linux-gnu/libboost_system.a
/usr/lib/x86_64-linux-gnu/libboost_system.so
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1

和:

$ sudo apt install libboost-all-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libboost-all-dev is already the newest version (1.65.1.0ubuntu1).

我以前使用过自动编译功能1.63.0,但是从/usr/local/lib和中删除了所有文件/usr/local/include也许它仍然以某种方式在这里困扰。

如果我发现这样的Boost(没有系统):

find_package(Boost 1.63.0 REQUIRED)

..then配置成功,但不会链接到${Boost_SYSTEM_LIBRARY}

/usr/bin/ld: src/app/CMakeFiles/app.dir/application.cpp.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
//usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
乔兹林

问题是您应该要求system而不是SYSTEM即使它抱怨使用boost_systemSYSTEM丢失我发现这有点令人困惑:

find_package(Boost 1.63.0 REQUIRED system)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章