Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake cannot find boost_program_options on Debian

I need Boost and some component libraries, including program_options, but CMake's FIND_PACKAGE command fails on Debian due to library version naming. How can I force it to find the program_options library in the cleanest way possible?

# CMakeLists.txt
SET( Boost_USE_STATIC_LIBS FALSE )
SET( Boost_USE_MULTITHREADED FALSE )
FIND_PACKAGE( Boost COMPONENTS program_options system thread REQUIRED)

This results in the following:

Unable to find the requested Boost libraries.

Boost version: 1.54.0

Boost include path: /usr/include

The following Boost libraries could not be found:

        boost_program_options

Examining my boost libraries:

$ ls -F /usr/lib | grep boost
libboost_program_options.so.1.49.0
libboost_program_options.so.1.54.0
libboost_system.a
libboost_system.so@
libboost_system.so.1.54.0
libboost_thread.a
libboost_thread.so@
libboost_thread.so.1.49.0
libboost_thread.so.1.54.0

Notice that program_options is the only one without an unversioned name (the other libraries provide links (denoted by the @ above) e.g. libboost_system.so -> libboost_system.so.1.54.0). As far as I can tell, Debian 7.2 does not provide a package that creates such a link, and therefore causes program_options not to be found. What can I do that doesn't include manually making the link (I cannot expect others using my package to be able to do that).

$ cmake -DBoost_DEBUG=ON
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:961 ] Searching for PROGRAM_OPTIONS_LIBRARY_RELEASE: boost_program_options-gcc47-1_54;boost_program_options-gcc47;boost_program_options-1_54;boost_program_options;boost_program_options
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:993 ] Searching for PROGRAM_OPTIONS_LIBRARY_DEBUG: boost_program_options-gcc47-d-1_54;boost_program_options-gcc47-d;boost_program_options-d-1_54;boost_program_options-d;boost_program_options;boost_program_options
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:961 ] Searching for SYSTEM_LIBRARY_RELEASE: boost_system-gcc47-1_54;boost_system-gcc47;boost_system-1_54;boost_system;boost_system
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:993 ] Searching for SYSTEM_LIBRARY_DEBUG: boost_system-gcc47-d-1_54;boost_system-gcc47-d;boost_system-d-1_54;boost_system-d;boost_system;boost_system
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:961 ] Searching for THREAD_LIBRARY_RELEASE: boost_thread-gcc47-1_54;boost_thread-gcc47;boost_thread-1_54;boost_thread;boost_thread
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:993 ] Searching for THREAD_LIBRARY_DEBUG: boost_thread-gcc47-d-1_54;boost_thread-gcc47-d;boost_thread-d-1_54;boost_thread-d;boost_thread;boost_thread
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1107 ] Boost_FOUND = FALSE
like image 817
Philip G. Lee Avatar asked Dec 10 '13 18:12

Philip G. Lee


2 Answers

Nevermind, turns out installing libboost-program-options-dev makes the link.

like image 144
Philip G. Lee Avatar answered Sep 30 '22 06:09

Philip G. Lee


For recent boost-versions (currently e.g. 1.72)

Alternatively, when requiring more recent versions (e.g. currently 1.72) which are not found as deb, then you can build/install the program_options package from the boost.org-website using the default-easy-build-instructions with the commands in the unzipped boost-folder (e.g. .../boost_1_72_0/):

$ sudo ./bootstrap.sh --with-libraries=program_options

$ sudo ./b2 install

Possibly, you may follow the complete boost-installation for boost, and previously uninstalling the deb (sudo apt-get remove libboost<version>).

like image 43
drstoop Avatar answered Sep 30 '22 07:09

drstoop