67

I tried everything like:

  1. Configure environment variable
  2. Make fresh build
  3. Re-install BOOST from source
  4. sudo apt-get install libboost-all-dev

But still getting following Errors:

CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1131 (message):
 Unable to find the requested Boost libraries.

 Unable to find the Boost header files.  Please set BOOST_ROOT to the root
 directory containing Boost or BOOST_INCLUDEDIR to the directory containing
 Boost's headers.
Call Stack (most recent call first):
   CMakeLists.txt:147 (find_package)


CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1131 (message):
Unable to find the requested Boost libraries.

Unable to find the Boost header files.  Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.

Source code directory for boost: /usr/local/src/boost_1_45_0 Boost Library path: /usr/local/lib Boost Header file: /usr/local/include/boost

Here is bashrc file:

BOOST_ROOT="/usr/local/src/boost_1_45_0"
Boost_LIBRARY_DIRS="/usr/local/lib"
BOOST_INCLUDEDIR="/usr/local/src/boost_1_45_0"

How to solve these Errors? Am i missing something?

Edit:

cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN -DBOOST_ROOT=/usr/local/src/boost_1_45_0 -DBOOST_INCLUDEDIR=/usr/local/include/boost -DBOOST_LIBRARYDIR=/usr/local/lib -DPYTHON_LIBRARIES=/usr/local/lib/python2.7 -DPYTHON_INCLUDE_DIRS=/usr/include/python2.7 -DCMA-DRDK_BUILD_PYTHON_WRAPPERS=
Community
  • 1
  • 1
Amit Pal
  • 10,604
  • 26
  • 80
  • 160
  • Can you show the output of CMake if you do `cmake . -DBoost_DEBUG=ON`? – Fraser Jun 11 '14 at 22:03
  • @Fraser :http://pastebin.com/cPRNegEi BTW my boost version is 1_45_0 – Amit Pal Jun 11 '14 at 22:05
  • 3
    Looks like it's not picking up the environment variables. See lines 8-10 of your output. You can try passing these as CMake variables. Maybe even just BOOST_ROOT would be enough: `cmake . -DBOOST_ROOT=/usr/local` – Fraser Jun 11 '14 at 22:10
  • @Fraser: Would it be `cmake . -DBOOST_ROOT=/usr/local/src/boost_1_45_0` ? Tried and got the same Error :( – Amit Pal Jun 11 '14 at 22:13
  • Did you build Boost from source in /usr/local/src/boost_1_45_0? Does CMake's debug output at least now show that it's looking in /usr/local/src/boost_1_45_0 ? – Fraser Jun 11 '14 at 22:26
  • Yes, I build it from given directory Here is the log: http://pastebin.com/caQiBRcv – Amit Pal Jun 11 '14 at 22:40
  • So you have a file /usr/local/src/boost_1_45_0/boost/version.hpp ? – Fraser Jun 11 '14 at 22:44
  • Yes, and here is the content: http://pastebin.com/ZSHRxMch – Amit Pal Jun 11 '14 at 22:46
  • This could be a permissions thing then. Can you access these without sudo? – Fraser Jun 11 '14 at 22:54
  • @Fraser: Check the updated Edit section in question. After running this command i got this: http://pastebin.com/LakszjG2 – Amit Pal Jun 11 '14 at 23:00
  • Looks like Boost is now found then. The python errors should probably be a new question, but I'd expect if you do `sudo apt-get install libpython-dev` then CMake would find them automatically. Not sure how cross-compiling affects this. Was the Boost thing a permission issue then? – Fraser Jun 11 '14 at 23:06
  • @Fraser: It's already installed..No, It was not a permission issue. WOuld it be any alternative for python? What if i want to disable it? – Amit Pal Jun 11 '14 at 23:08
  • 1
    Be good to know what the Boost problem was. As for Python while cross-compiling, I can't really help too much. It looks like you can disable CMake trying to find Python by editing the CMakeLIsts.txt file around line 114, but if they've made it required, probably it's being used unconditionally somewhere else, and you'll then just get a failure at that point. Like I said, probably time for a new question :-) – Fraser Jun 11 '14 at 23:18
  • 6
    @AmitPal Please add an answer yourself instead of editing the answer into your question, that way people can see that the question is answered. – Andreas Haferburg Jun 12 '14 at 12:51
  • 6
    @AmitPal - Did that last line under EDIT fix the problem? If, YES, then answer your own question so people will the the question is answered, as Andreas Haferburg said in his comment above. – Patricia Apr 09 '15 at 15:52
  • Some versions of Boost use the flag `Boost_INCLUDE_DIR` and others use the flag `Boost_INCLUDEDIR` (**without the underscore**). You can check the right one for your case by reading the `FindBoost.cmake` file, under `path-to-cmake/Modules/FindBoost.cmake` – marcelosalloum Jul 05 '19 at 14:02
  • Try adding `-DBoost_DEBUG=TRUE` to your `cmake` command line to see where the `FindBoost` macro is searching. – Andrew Marshall Feb 28 '19 at 12:32
  • @AmitPal Could you answer Andreas and Patricia 's question ? – Stephane Jun 13 '21 at 14:35

8 Answers8

57

Try to complete cmake process with following libs:

sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev
sKhan
  • 9,694
  • 16
  • 55
  • 53
Aleksandr Ianevski
  • 1,894
  • 1
  • 18
  • 22
17

I'm using this to set up boost from cmake in my CMakeLists.txt. Try something similar (make sure to update paths to your installation of boost).

SET (BOOST_ROOT "/opt/boost/boost_1_57_0")
SET (BOOST_INCLUDEDIR "/opt/boost/boost-1.57.0/include")
SET (BOOST_LIBRARYDIR "/opt/boost/boost-1.57.0/lib")

SET (BOOST_MIN_VERSION "1.55.0")
set (Boost_NO_BOOST_CMAKE ON)
FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)
if (NOT Boost_FOUND)
  message(FATAL_ERROR "Fatal error: Boost (version >= 1.55) required.")
else()
  message(STATUS "Setting up BOOST")
  message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
  message(STATUS " Library  - ${Boost_LIBRARY_DIRS}")
  include_directories(${Boost_INCLUDE_DIRS})
  link_directories(${Boost_LIBRARY_DIRS})
endif (NOT Boost_FOUND)

This will either search default paths (/usr, /usr/local) or the path provided through the cmake variables (BOOST_ROOT, BOOST_INCLUDEDIR, BOOST_LIBRARYDIR). It works for me on cmake > 2.6.

paul-g
  • 3,797
  • 2
  • 21
  • 36
14

I got the same error the first time I wanted to install LightGBM on python (GPU version).

You can simply fix it with this command line :

sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev

the boost libraries will be installed and you'll be fine to continue your installation process.

smerllo
  • 3,117
  • 1
  • 22
  • 37
1

seems the answer is in the comments and as an edit but to clarify this should work for you:

export BUILDDIR='your path to  build directory here'
export SRCDIR='your path to source dir here'
export BOOST_ROOT="/opt/boost/boost_1_57_0"
export BOOST_INCLUDE="/opt/boost/boost-1.57.0/include"
export BOOST_LIBDIR="/opt/boost/boost-1.57.0/lib"
export BOOST_OPTS="-DBOOST_ROOT=${BOOST_ROOT} -DBOOST_INCLUDEDIR=${BOOST_INCLUDE} -DBOOST_LIBRARYDIR=${BOOST_LIBDIR}"
(cd ${BUILDDIR} && cmake ${BOOST_OPTS} ${SRCDIR})

you need to specify the arguments as command line arguments or you can use a toolchain file for that, but cmake will not touch your environment variables.

Alexander Oh
  • 24,223
  • 14
  • 73
  • 76
1

I just want to point out that the FindBoost macro might be looking for an earlier version, for instance, 1.58.0 when you might have 1.60.0 installed. I suggest popping open the FindBoost macro from whatever it is you are attempting to build, and checking if that's the case. You can simply edit it to include your particular version. (This was my problem.)

Ganta
  • 19
  • 1
1

Thanks Paul-g for your advise. For my part it was a bit different.

I installed Boost by following the Step 5 of : https://www.boost.org/doc/libs/1_59_0/more/getting_started/unix-variants.html

And then I add PATH directory in the "FindBoos.cmake", located in /usr/local/share/cmake-3.5/Modules :

SET (BOOST_ROOT "../boost_1_60_0")
SET (BOOST_INCLUDEDIR "../boost_1_60_0/boost")
SET (BOOST_LIBRARYDIR "../boost_1_60_0/libs")

SET (BOOST_MIN_VERSION "1.55.0")
set (Boost_NO_BOOST_CMAKE ON)
0

Long answer to short, if you install boost in custom path, all header files must in ${path}/boost/.

if you want to konw why cmake can't find the requested Boost libraries after you have set BOOST_ROOT/BOOST_INCLUDEDIR, you can check cmake install location path_to_cmake/share/cmake-xxx/Modules/FindBoost.

cmake which will find Boost_INCLUDE_DIR in boost/config.hpp in BOOST_ROOT. That means your boost header file must in ${path}/boost/, any other format (such as ${path}/boost-x.y.z) will not be suitable for find_package in CMakeLists.txt.

0

I had the same issue inside an alpine docker container, my solution was to add the boost-dev apk library because libboost-dev was not available.