Cmake可以找到提升而不是提升核心

时间:2018-05-08 20:04:39

标签: boost cmake

我已经在Ubuntu上安装了libboost-all-dev

Cmake 3.10.2可以找到提升而不是" 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)

1 个答案:

答案 0 :(得分:1)

据我所知,没有这样的升级库core。您可以检查库是否应该链接hereBoost.Iterator是一个仅限标题的库,因此您无需链接任何内容。只需加入<boost/iterator/...>即可。如果您不能包含,请检查这些包含是否实际存在于您当地的boost发行版中。

我检查了boost::counting_iterator<int>,一切都适合我。

相关问题