Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake reports 'Boost_DIR-NOT_FOUND' when trying to find Boost

Tags:

boost

cmake

I want to build a library called CSWNet on my machine. Cmake can find Boost_INCLUDE_DIR and Boost_LIB_DIR but it cannot find an option called Boost_DIR which is a directory containing a CMake configuration file for Boost. Where is it? Please help, thanks ahead. The error I got is shown below and I installed boost from ubuntu repository and it's installed in /usr/local.

 CMake Error at /usr/local/share/cmake-2.8/Modules/FindBoost.cmake:429 (message):
When requesting a specific version of Boost, you must provide at least the
major and minor version numbers, e.g., 1.34
Call Stack (most recent call first):
demos/CMakeLists.txt:149 (find_package)
like image 717
Juneyee Avatar asked Dec 12 '22 13:12

Juneyee


2 Answers

It seems you misunderstood the meaning of Boost_DIR.

Boost_DIR is an environment variable used as a hint by CMake to find the boost installation directory. If this is set to Boost_DIR-NOTFOUND that does not mean that it did not find Boost. Boost_FOUND is used to indicate whether the search was successful:

find_package(Boost REQUIRED thread)
if(Boost_FOUND)
    message(STATUS "Success!")
endif()

In case of a successful search, CMake will also print a diagnostic message during the configure phase which looks something like

Boost version: 1.53.0
Found the following Boost libraries:
  thread
like image 92
ComicSansMS Avatar answered May 19 '23 20:05

ComicSansMS


Hope its not too late to post this. Passing it in the command line along with cmake command would resovle it

 cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=dist -DBOOST_DIR="boost installation location"
like image 30
ravi.zombie Avatar answered May 19 '23 19:05

ravi.zombie