cmake 3.0.2 can't find boost on 14.04
Solution 1
What version of libboost-all-dev
are you using? I assume you are using v1.53.0.
Try installing libboost1.54-all-dev
instead.
Solution 2
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.
Solution 3
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.
Solution 4
I also meet such awkward situation in ubuntu...
My solution is simply not use find_package
but adding the libraries in the link process
target_link_libraries( your_program boost_system boost_filesystem ... )
The bad things is that cmake
cannot examine the existence of the boost
library. However, it simply works.
Hope someone can figure out a better solution.
Related videos on Youtube
GLaz
Updated on September 18, 2022Comments
-
GLaz over 1 year
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.
-
Jithin Pavithran almost 8 yearsuse
sudo apt-get install libboost-all-dev
-
littleguga almost 4 years@JithinPavithran thank you it helped!