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 also encountered the same problem, but trying the hints here didn't help, unfortunately.
The only thing that helped was to download the newest version from the Boost page, compile and install it as described in Installing Boost 1.50 on Ubuntu 12.10.
In my case I worked with Boost 1.53.
Generally the most common mistake is not cleaning your build directory after adding new options. I have Boost installed from system packet manager. Its version is 1.49.
I also downloaded Boost 1.53 and "installed" it under
$HOME/installs
.The only thing that I had to do in my project was to (I keep sources in
my_project_directory/src
):And that's it. Ta bum tss.
But if I'd make after
cd build
->cmake ../src
it would set Boost from the system path. Then doingcmake -DCMAKE_INCLUDE_PATH=$HOME/installs/include -DCMAKE_LIBRARY_PATH=$HOME/installs/lib ../src
would change nothing.You have to clean your build directory (
cd build && rm -rf *
;) )There is a generic method to give CMake directions about where to find libraries.
When looking for a library, CMake looks first in the following variables:
CMAKE_LIBRARY_PATH
andLD_LIBRARY_PATH
for librariesCMAKE_INCLUDE_PATH
andINCLUDE_PATH
for includesIf you declare your Boost files in one of the environment variables, CMake will find it. Example:
If it's too cumbersome, you can also use a nice installing tool I wrote that will do everything for you: C++ version manager
The short version
You only need
BOOST_ROOT
, but you're going to want to disable searching the system for your local Boost if you have multiple installations or cross-compiling for iOS or Android. In which case addBoost_NO_SYSTEM_PATHS
is set to false.Normally this is passed on the CMake command-line using the syntax
-D<VAR>=value
.The longer version
Officially speaking the FindBoost page states these variables should be used to 'hint' the location of Boost.
This makes a theoretically correct incantation:
When you compile from source
Then when you call this script you'll need to include the boost.cmake script (mine is in the a subdirectory), include the headers, indicate the dependency, and link the libraries.
While configure could find my Boost installation, CMake could not.
Locate FindBoost.cmake and look for LIBRARY_HINTS to see what sub-packages it is looking for. In my case it wanted the MPI and graph libraries.
apt-cache search ... I installed the dev packages since I was building code, and the dev package drags in all the dependencies. I'm not so sure that a standard Boost install needs Open MPI, but this is OK for now.
I had a similar issue, and I could use customized Boost libraries by adding the below lines to my
CMakeLists.txt
file: