I have installed the most recent version of Boost in /usr/local
(with includes in /usr/local/include/boost
and libraries in /usr/local/lib/boost
) and I am now attempting to install Wt from source, but CMake (version 2.6) can't seem to find the Boost installation. It tries to give helpful suggestions about setting BOOST_DIR and Boost_LIBRARYDIR, but I haven't been able to get it to work by tweaking these variables.
The most recent error message that I get is that it can't find the libraries, but it seems to indicate that it is using "/usr/local/include" for the include path, which isn't correct (and I can't seem to fix it). Is there a solution for this off the top of their head, or do I need to go mucking around inside CMake to figure it out?
I spent most of my evening trying to get this working. I tried all of the -DBOOST_* &c. directives with CMake, but it kept linking to my system Boost libraries, even after clearing and re-configuring my build area repeatedly.
At the end I modified the generated Makefile and voided the cmake_check_build_system target to do nothing (like 'echo ""') so that it wouldn't overwrite my changes when I ran make, and then did 'grep -rl "lboost_python" * | xargs sed -i "s:-lboost_python:-L/opt/sw/gcc5/usr/lib/ -lboost_python:g' in my build/ directory to explicitly point all the build commands to the Boost installation I wanted to use. Finally, that worked.
I acknowledge that it is an ugly kludge, but I am just putting it out here for the benefit of those who come up against the same brick wall, and just want to work around it and get work done.
I ran into a similar problem on a Linux server, where two versions of Boost have been installed. One is the precompiled 1.53.0 version which counts as old in 2018; it's in
/usr/include
and/usr/lib64
. The version I want to use is 1.67.0, as a minimum version of 1.65.1 is required for another C++ library I'm installing; it's in/opt/boost
, which hasinclude
andlib
subdirectories. As suggested in previous answers, I set variables inCMakeLists.txt
to specify where to look for Boost 1.67.0 as followsBut CMake doesn't honor those changes. Then I found an article online: CMake can use a local Boost, and realized that I need to change the variables in
CMakeCache.txt
. There I found that the Boost-related variables are still pointing to the default Boost 1.53.0, so no wonder CMake doesn't honor my changes inCMakeLists.txt
. Then I set the Boost-related variables inCMakeCache.txt
I also changed the variables pointing to the non-header, compiled parts of the Boost library to point to the version I want. Then CMake successfully built the library that depends on a recent version of Boost.
You should have a look at
FindBoost.cmake
script, which handles Boost detection and setting up all Boost variables. It typically resides in/usr/share/cmake-2.6/Modules/
. In it, you will find documentation. For instance:In contrast to BOOST_ROOT, the variables you are referring to are actually variables that are set by the FindBoost module. Note that you don't have to (and probably also don't want to) edit your CMake project configuration to set BOOST_ROOT. Instead, you should use the environment variable, e.g. calling
# BOOST_ROOT=/usr/local/... ccmake .
I was finally able to get what I wanted with
I had a similar issue, CMake finding a vendor-installed Boost only, but my cluster had a locally installed version which is what I wanted it to use. Red Hat Linux 6.
Anyway, it looks like all the
BOOSTROOT
,BOOST_ROOT
, andBoost_DIR
stuff would get annoyed unless one also setsBoost_NO_BOOST_CMAKE
(e.g add to cmd line-DBoost_NO_BOOST_CMAKE=TRUE
).(I will concede the usefulness of CMake for multiplatform, but I can still hate it.)
After digging around in CMake and experimenting, I determined that CMake was unhappy with the fact that all of my Boost libraries were contained in
/usr/local/lib/boost
and not/usr/local/lib
. Once I soft-linked them back out, the build worked.