R zu
R zu

Reputation: 2064

Cmake can find boost but not boost core

I have installed the libboost-all-dev packaged on Ubuntu.

Cmake 3.10.2 can find boost but not "boost_core".

When I change the find package line to:

find_package(Boost REQUIRED COMPONENTS core)

Then it complains that it can't find "boost_core".

I actually just need boost/iterator...

How to make cmake find that?

Thanks.

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)

Success message (before replacing the find_package line):

-- Boost version: 1.65.1
-- Configuring done
-- Generating done

Error message (after replacing the find_package line)

  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)

Upvotes: 0

Views: 583

Answers (1)

NuPagadi
NuPagadi

Reputation: 1440

As I know there is no such a boost library core. You can check if a library should be linked here. And Boost.Iterator is a header-only library, so you don't need to link anything. Just include <boost/iterator/...>. If you can't include, check whether these includes actually exist in your local boost distro.

I checked it for boost::counting_iterator<int> and all works well for me.

Upvotes: 1

Related Questions