【发布时间】:2018-05-08 20:04:38
【问题描述】:
我已经在 Ubuntu 上安装了 libboost-all-dev。
Cmake 3.10.2 可以找到 boost 但找不到 "boost_core"。
当我将查找包行更改为:
find_package(Boost REQUIRED COMPONENTS core)
然后它抱怨找不到“boost_core”。
其实我只需要boost/iterator...
如何让 cmake 找到它?
谢谢。
CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(test_boost_iterator)
set(CMAKE_CXX_STANDARD 11)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
add_definitions( "-DHAS_BOOST" )
add_executable(test_boost_iterator main.cpp)
成功消息(在替换find_package 行之前):
-- Boost version: 1.65.1
-- Configuring done
-- Generating done
错误信息(替换find_package 行后)
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_core
No Boost libraries were found. You may need to 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:6 (find_package)
【问题讨论】:
-
在您的代码 sn-p 中,您没有为
find_package指定COMPONENTS。 -
是的。这在我将
find_package行更改为find_package(Boost REQUIRED COMPONENTS core)之前有效