Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake does not find boost header on linux

Boost header files are on /usr/include/boost.

In CMakeLists.txt I include the folder with include_directories

include_directories(/usr/include /usr/include/boost/  
/usr/include/boost/smart_ptr)

However, cmake insists in not finding header files. The problem arises in intrusive_ptr.hpp, which includes #include <boost/smart_ptr/intrusive_ptr.hpp:

boost/smart_ptr/intrusive_ptr.hpp: No such file or directory
/usr/include/boost/intrusive_ptr.hpp

My guess is it does not like boost/smart_ptr/ prefix.

So, include_directories did not work.

CMake Error:

CMake Error at /usr/local/share/cmake-3.3/Modules/FindBoost.cmake:1245   
(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.

What should I do?

Thanks.

like image 777
Mert Mertce Avatar asked Jan 20 '26 02:01

Mert Mertce


1 Answers

While I do not know what failed in your case, I'd recommend to simply use find_package with the included FindBoost.cmake file:

find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

Done

like image 86
rettichschnidi Avatar answered Jan 21 '26 17:01

rettichschnidi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!