11

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?

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
Pietro
  • 12,086
  • 26
  • 100
  • 193
  • 1
    Please have a look : How can I get cmake to find my boost installation ? http://stackoverflow.com/questions/3016448/how-can-i-get-cmake-to-find-my-boost-installation/13862264#13862264 – Offirmo Jun 14 '13 at 12:41
  • 1
    @Offirmo: Unfortunately I need to build it on Windows 7. – Pietro Jun 14 '13 at 14:12
  • 2
    Try running `cmake . -DBoost_DEBUG=ON` to get more info about what CMake is doing. If it doesn't find an appropriate version of boost in the `BOOST_ROOT` path you specified, it'll carry on looking in system folders. The 1.53 version may not be suitable e.g. if you compiled boost into shared libs, but in your CMakeLists.txt you haven't specified `set(Boost_USE_STATIC_LIBS OFF)`. – Fraser Jun 14 '13 at 15:15
  • @Fraser: in my CMakeLists.txt file I have: `SET(Boost_USE_STATIC_LIBS ON)` and `SET(Boost_USE_STATIC_RUNTIME ON)`. – Pietro Jun 17 '13 at 08:31
  • @Pietro - That was just an example of what could go wrong. It'd be easiest to debug if you paste the output of running `cmake . -DBoost_DEBUG=ON` and also provide the full names of the boost 1.53 libraries (the names usually give a good bit of info about how the libs were built) – Fraser Jun 17 '13 at 09:08

3 Answers3

24

Try this:

cmake -DBOOST_ROOT=path
chrisaycock
  • 36,470
  • 14
  • 88
  • 125
Magog
  • 485
  • 4
  • 13
12

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?

Community
  • 1
  • 1
phobon
  • 121
  • 1
  • 5
6

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.

Liosan
  • 7,520
  • 2
  • 17
  • 16