Linux Mint 19上的CMake 3.11无法找到静态Boost库

时间:2018-08-22 16:25:58

标签: c++ linux boost cmake

我正在研究一个项目,并使用CMake构建该项目。该项目在Windows上可以完美运行,但我想使用相同的CMakeLists.txt文件制作Linux变体。

这是我的CMakeLists.txt文件的相关部分:

if(WIN32)
    set(BOOST_ROOT "C:\\Boost")
    set(BOOST_INCLUDEDIR "C:\\Boost\\include\\boost-1_68")
endif(WIN32)
if(UNIX)
    set(Boost_DEBUG ON)
    set(Boost_NAMESPACE "libboost")
    set(Boost_USE_STATIC_RUNTIME OFF)
endif(UNIX)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_DEBUG_LIBS OFF)
find_package(Boost REQUIRED random filesystem serialization)
include_directories(${Boost_INCLUDE_DIRS})

我使用sudo apt install libboost_all-dev命令安装了Boost。

尝试配置项目时出现以下错误。

CMake Error at /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/
  FindBoost.cmake:2044 (message):
Unable to find the requested Boost libraries.

Boost version: 1.65.1

Boost include path: /usr/include

Could not find the following static Boost libraries:

      libboost_random
      libboost_filesystem
      libboost_serialization

Some (but not all) of the required Boost libraries were found.  You may
need to install these additional Boost libraries.  Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:49 (find_package)
...

这是完整的输出。

/opt/clion-2018.2/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /home/dave/CLionProjects/FNDice-win
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1121 ] _boost_TEST_VERSIONS = 1.68.0;1.68;1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1123 ] Boost_USE_MULTITHREADED = TRUE
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1125 ] Boost_USE_STATIC_LIBS = ON
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1127 ] Boost_USE_STATIC_RUNTIME = OFF
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1129 ] Boost_ADDITIONAL_VERSIONS = 
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1131 ] Boost_NO_SYSTEM_PATHS = 
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1199 ] Declared as CMake or Environmental Variables:
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1201 ]   BOOST_ROOT = 
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1203 ]   BOOST_INCLUDEDIR = 
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1205 ]   BOOST_LIBRARYDIR = 
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1207 ] _boost_TEST_VERSIONS = 1.68.0;1.68;1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1282 ] Include debugging info:
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1284 ]   _boost_INCLUDE_SEARCH_DIRS = PATHS;C:/boost/include;C:/boost;/sw/local/include
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1286 ]   _boost_PATH_SUFFIXES = boost-1_68_0;boost_1_68_0;boost/boost-1_68_0;boost/boost_1_68_0;boost-1_68;boost_1_68;boost/boost-1_68;boost/boost_1_68;boost-1_67_0;boost_1_67_0;boost/boost-1_67_0;boost/boost_1_67_0;boost-1_67;boost_1_67;boost/boost-1_67;boost/boost_1_67;boost-1_66_0;boost_1_66_0;boost/boost-1_66_0;boost/boost_1_66_0;boost-1_66;boost_1_66;boost/boost-1_66;boost/boost_1_66;boost-1_65_1;boost_1_65_1;boost/boost-1_65_1;boost/boost_1_65_1;boost-1_65_0;boost_1_65_0;boost/boost-1_65_0;boost/boost_1_65_0;boost-1_65;boost_1_65;boost/boost-1_65;boost/boost_1_65;boost-1_64_0;boost_1_64_0;boost/boost-1_64_0;boost/boost_1_64_0;boost-1_64;boost_1_64;boost/boost-1_64;boost/boost_1_64;boost-1_63_0;boost_1_63_0;boost/boost-1_63_0;boost/boost_1_63_0;boost-1_63;boost_1_63;boost/boost-1_63;boost/boost_1_63;boost-1_62_0;boost_1_62_0;boost/boost-1_62_0;boost/boost_1_62_0;boost-1_62;boost_1_62;boost/boost-1_62;boost/boost_1_62;boost-1_61_0;boost_1_61_0;boost/boost-1_61_0;boost/boost_1_61_0;boost-1_61;boost_1_61;boost/boost-1_61;boost/boost_1_61;boost-1_60_0;boost_1_60_0;boost/boost-1_60_0;boost/boost_1_60_0;boost-1_60;boost_1_60;boost/boost-1_60;boost/boost_1_60;boost-1_59_0;boost_1_59_0;boost/boost-1_59_0;boost/boost_1_59_0;boost-1_59;boost_1_59;boost/boost-1_59;boost/boost_1_59;boost-1_58_0;boost_1_58_0;boost/boost-1_58_0;boost/boost_1_58_0;boost-1_58;boost_1_58;boost/boost-1_58;boost/boost_1_58;boost-1_57_0;boost_1_57_0;boost/boost-1_57_0;boost/boost_1_57_0;boost-1_57;boost_1_57;boost/boost-1_57;boost/boost_1_57;boost-1_56_0;boost_1_56_0;boost/boost-1_56_0;boost/boost_1_56_0;boost-1_56;boost_1_56;boost/boost-1_56;boost/boost_1_56;boost-1_55_0;boost_1_55_0;boost/boost-1_55_0;boost/boost_1_55_0;boost-1_55;boost_1_55;boost/boost-1_55;boost/boost_1_55;boost-1_54_0;boost_1_54_0;boost/boost-1_54_0;boost/boost_1_54_0;boost-1_54;boost_1_54;boost/boost-1_54;boost/boost_1_54;boost-1_53_0;boost_1_53_0;boost/boost-1_53_0;boost/boost_1_53_0;boost-1_53;boost_1_53;boost/boost-1_53;boost/boost_1_53;boost-1_52_0;boost_1_52_0;boost/boost-1_52_0;boost/boost_1_52_0;boost-1_52;boost_1_52;boost/boost-1_52;boost/boost_1_52;boost-1_51_0;boost_1_51_0;boost/boost-1_51_0;boost/boost_1_51_0;boost-1_51;boost_1_51;boost/boost-1_51;boost/boost_1_51;boost-1_50_0;boost_1_50_0;boost/boost-1_50_0;boost/boost_1_50_0;boost-1_50;boost_1_50;boost/boost-1_50;boost/boost_1_50;boost-1_49_0;boost_1_49_0;boost/boost-1_49_0;boost/boost_1_49_0;boost-1_49;boost_1_49;boost/boost-1_49;boost/boost_1_49;boost-1_48_0;boost_1_48_0;boost/boost-1_48_0;boost/boost_1_48_0;boost-1_48;boost_1_48;boost/boost-1_48;boost/boost_1_48;boost-1_47_0;boost_1_47_0;boost/boost-1_47_0;boost/boost_1_47_0;boost-1_47;boost_1_47;boost/boost-1_47;boost/boost_1_47;boost-1_46_1;boost_1_46_1;boost/boost-1_46_1;boost/boost_1_46_1;boost-1_46_0;boost_1_46_0;boost/boost-1_46_0;boost/boost_1_46_0;boost-1_46;boost_1_46;boost/boost-1_46;boost/boost_1_46;boost-1_45_0;boost_1_45_0;boost/boost-1_45_0;boost/boost_1_45_0;boost-1_45;boost_1_45;boost/boost-1_45;boost/boost_1_45;boost-1_44_0;boost_1_44_0;boost/boost-1_44_0;boost/boost_1_44_0;boost-1_44;boost_1_44;boost/boost-1_44;boost/boost_1_44;boost-1_43_0;boost_1_43_0;boost/boost-1_43_0;boost/boost_1_43_0;boost-1_43;boost_1_43;boost/boost-1_43;boost/boost_1_43;boost-1_42_0;boost_1_42_0;boost/boost-1_42_0;boost/boost_1_42_0;boost-1_42;boost_1_42;boost/boost-1_42;boost/boost_1_42;boost-1_41_0;boost_1_41_0;boost/boost-1_41_0;boost/boost_1_41_0;boost-1_41;boost_1_41;boost/boost-1_41;boost/boost_1_41;boost-1_40_0;boost_1_40_0;boost/boost-1_40_0;boost/boost_1_40_0;boost-1_40;boost_1_40;boost/boost-1_40;boost/boost_1_40;boost-1_39_0;boost_1_39_0;boost/boost-1_39_0;boost/boost_1_39_0;boost-1_39;boost_1_39;boost/boost-1_39;boost/boost_1_39;boost-1_38_0;boost_1_38_0;boost/boost-1_38_0;boost/boost_1_38_0;boost-1_38;boost_1_38;boost/boost-1_38;boost/boost_1_38;boost-1_37_0;boost_1_37_0;boost/boost-1_37_0;boost/boost_1_37_0;boost-1_37;boost_1_37;boost/boost-1_37;boost/boost_1_37;boost-1_36_1;boost_1_36_1;boost/boost-1_36_1;boost/boost_1_36_1;boost-1_36_0;boost_1_36_0;boost/boost-1_36_0;boost/boost_1_36_0;boost-1_36;boost_1_36;boost/boost-1_36;boost/boost_1_36;boost-1_35_1;boost_1_35_1;boost/boost-1_35_1;boost/boost_1_35_1;boost-1_35_0;boost_1_35_0;boost/boost-1_35_0;boost/boost_1_35_0;boost-1_35;boost_1_35;boost/boost-1_35;boost/boost_1_35;boost-1_34_1;boost_1_34_1;boost/boost-1_34_1;boost/boost_1_34_1;boost-1_34_0;boost_1_34_0;boost/boost-1_34_0;boost/boost_1_34_0;boost-1_34;boost_1_34;boost/boost-1_34;boost/boost_1_34;boost-1_33_1;boost_1_33_1;boost/boost-1_33_1;boost/boost_1_33_1;boost-1_33_0;boost_1_33_0;boost/boost-1_33_0;boost/boost_1_33_0;boost-1_33;boost_1_33;boost/boost-1_33;boost/boost_1_33
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1306 ] location of version.hpp: /usr/include/boost/version.hpp
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1330 ] version.hpp reveals boost 1.65.1
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1416 ] guessed _boost_COMPILER = -gcc73
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1426 ] _boost_MULTITHREADED = -mt
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1502 ] _boost_RELEASE_ABI_TAG = -
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1504 ] _boost_DEBUG_ABI_TAG = -d
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1567 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/include/lib;/usr/include/../lib;/usr/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG   = /usr/include/lib;/usr/include/../lib;/usr/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1756 ] Searching for RANDOM_LIBRARY_RELEASE: libboost_random-gcc73-mt-1_65_1;libboost_random-gcc73-mt;libboost_random-mt-1_65_1;libboost_random-mt;libboost_random
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1809 ] Searching for RANDOM_LIBRARY_DEBUG: libboost_random-gcc73-mt-d-1_65_1;libboost_random-gcc73-mt-d;libboost_random-mt-d-1_65_1;libboost_random-mt-d;libboost_random-mt;libboost_random
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1756 ] Searching for FILESYSTEM_LIBRARY_RELEASE: libboost_filesystem-gcc73-mt-1_65_1;libboost_filesystem-gcc73-mt;libboost_filesystem-mt-1_65_1;libboost_filesystem-mt;libboost_filesystem
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1809 ] Searching for FILESYSTEM_LIBRARY_DEBUG: libboost_filesystem-gcc73-mt-d-1_65_1;libboost_filesystem-gcc73-mt-d;libboost_filesystem-mt-d-1_65_1;libboost_filesystem-mt-d;libboost_filesystem-mt;libboost_filesystem
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1756 ] Searching for SERIALIZATION_LIBRARY_RELEASE: libboost_serialization-gcc73-mt-1_65_1;libboost_serialization-gcc73-mt;libboost_serialization-mt-1_65_1;libboost_serialization-mt;libboost_serialization
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1809 ] Searching for SERIALIZATION_LIBRARY_DEBUG: libboost_serialization-gcc73-mt-d-1_65_1;libboost_serialization-gcc73-mt-d;libboost_serialization-mt-d-1_65_1;libboost_serialization-mt-d;libboost_serialization-mt;libboost_serialization
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1756 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-gcc73-mt-1_65_1;libboost_system-gcc73-mt;libboost_system-mt-1_65_1;libboost_system-mt;libboost_system
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1809 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-gcc73-mt-d-1_65_1;libboost_system-gcc73-mt-d;libboost_system-mt-d-1_65_1;libboost_system-mt-d;libboost_system-mt;libboost_system
-- [ /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:1883 ] Boost_FOUND = 1
CMake Error at /opt/clion-2018.2/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:2044 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.1

  Boost include path: /usr/include

  Could not find the following static Boost libraries:

          libboost_random
          libboost_filesystem
          libboost_serialization

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
  to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:49 (find_package)


-- Found wxWidgets: -L/usr/local/lib;-pthread;;;-lwx_baseu_net-3.1;-lwx_gtk3u_gl-3.1;-lwx_gtk3u_core-3.1;-lwx_baseu-3.1;-lwx_gtk3u_webview-3.1;-lwx_gtk3u_adv-3.1 (found version "3.1.1") 
-- Configuring incomplete, errors occurred!
See also "/home/dave/CLionProjects/FNDice-win/cmake-build-debug/CMakeFiles/CMakeOutput.log".

[Failed to reload]

1 个答案:

答案 0 :(得分:1)

验证库是否在包含路径中。这可能是您的cmake程序包或Boost程序包中的错误。

对我来说,在Fedora上,这些库位于/ usr / lib64中。在Ubuntu(以及来自what I could find,Linux Mint)上,它们应该位于/ usr / lib / x86_64-linux-gnu中。

一种临时解决方案是将目录添加到include_directories语句中。您可能还会发现this question有用。