cmake 3.0.2 can't find boost on 14.04
I have the latest cmake 3.0.2 compiled from sources, also libboost-all-dev installed. And find_package(Boost) can't find it. Here is output of cmake:
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost of BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Do I need to manually set any variables after installing Boost to get it visible for cmake?
Thanks.
What version of libboost-all-dev
are you using? I assume you are using v1.53.0.
Try installing libboost1.54-all-dev
instead.
In 14.04 (and probably earlier) to 16.04, I could use these:
find_package( Boost COMPONENTS filesystem system REQUIRED )
include_directories(
${BOOST_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
}
If you only need the headers, then you do not need to specify any component and no target_link_libraries()
:
find_package( Boost REQUIRED )
include_directories(
${BOOST_INCLUDE_DIRS}
)
With 16.10, I had to make sure to install libboost-all-dev
so my code would continue to compile on Ubuntu.
sudo apt-get install libboost-all-dev
Previous versions worked with just libboost-dev
, somehow. Although it looks like you already had that part figured out, I just wanted to make sure it was clearly mentioned that there was a recent change in that regard.
Thanks, Rohith.
As an alternative solution, I downloaded and built the latest version of boost and added BOOST_ROOT variable in ~/.profile like this:
export BOOST_ROOT=$HOME/work/boost_1_57_0
Note, that boost has to be built if you are using it's non-header libraries.