Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot specify BOOST_ROOT for cmake

I have multiple versions of Boost installed (Windows 7/MinGW). I need to use a particular one (1.53.0).

I defined BOOST_ROOT in the CMakeFiles.txt file: SET(BOOST_ROOT C:/boost_1_53_0/), but I keep getting this error:

> cmake .
BOOST_ROOT=C:/boost_1_53_0/
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1191 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.48.0

  Boost include path: C:/Boost/include/boost-1_48

  Detected version of Boost is too old.  Requested version was 1.53 (or
  newer).

  The following Boost libraries could not be found:

          boost_filesystem

  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.

I also defined BOOST_ROOT as an environment variable, but with the same result.

Why is cmake still looking for the old version?

like image 431
Pietro Avatar asked Jun 14 '13 12:06

Pietro


3 Answers

I also struggled with this same problem for a while. If this is the same issue that I had, then the problem is you aren't running the CMake configuration completely fresh without any cache. Once it runs once and finds the default installation (C:\Boost or /usr/include) it will continue to find that one regardless of the value of BOOST_ROOT. So make sure to completely delete any generated build files. Then set BOOST_ROOT to your desired separate installation and it should work fine.

This is also mentioned by jaor on the previously linked question: How can I get cmake to find my alternative boost installation?

like image 114
phobon Avatar answered Nov 17 '22 13:11

phobon


Try this:

cmake -DBOOST_ROOT=path
like image 45
Magog Avatar answered Nov 17 '22 15:11

Magog


If you are using a precompiled version of Boost libraries for Visual Studio, they come in a specific flavor of MSVC version and bitness. I needed to point CMake to that specific location - in my case, setting BOOST_ROOT to C:/local/boost_1_59_0 and BOOST_LIBRARYDIR to C:/local/boost_1_59_0/lib64-msvc-11.0 helped.

like image 39
Liosan Avatar answered Nov 17 '22 14:11

Liosan