我已经在Ubuntu上安装了打包的libboost-all-dev。
Cmake3.10.2可以找到助推,但找不到"boost_core“。
当我将find包行更改为:
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)发布于 2018-05-08 20:26:06
正如我所知,没有这样的boost库core。您可以检查库是否应该链接到这里。而且Boost.Iterator是一个只有头的库,所以您不需要链接任何东西。只要包括<boost/iterator/...>。如果您不能包括,检查这些包含是否实际存在于您本地的boost发行版中。
我检查了它的boost::counting_iterator<int>,所有的一切对我都很好。
https://stackoverflow.com/questions/50241483
复制相似问题