Issue
When trying to compile with boost, everything goes right with Windows, but when I try to compile with Linux, it seems that the configuration given with SET
command are not take in account by FindBoost.
When doing the following,
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED OFF)
find_package(Boost COMPONENTS system REQUIRED)
if (Boost_FOUND)
MESSAGE(${Boost_SYSTEM_LIBRARY})
endif ()
the output is /usr/lib/libboost_system-mt.a
which seems to be the static and multithreaded version off the library. What am I doing wrong?
Solution
If you look at FindBoost.cmake specifying Boost_USE_STATIC_LIBS as OFF uses the default suffix values for searching (CMAKE_FIND_LIBRARY_SUFFIXES) as opposed to overriding them. On my linux machine
MESSAGE(${CMAKE_FIND_LIBRARY_SUFFIXES})
returns
.so.a
So
set(Boost_USE_STATIC_LIBS OFF)
provides a hint that results in .so files getting preference over .a but will include them if no matching .so is found. That being the case, the problem is that you most likely do not have the shared objects installed or they are installed somewhere FindBoost.cmake isn't looking. To resolve this re-run cmake with
cmake -DBoost_DEBUG=ON
and look at the output to see where cmake is looking for the boost libraries and then check those locations to see if the .so files actually exist. If they exist make sure they are named in a way that will match the hints you set, e.g. libboost_system-mt.so won't match because you specified that multithreaded should be off.
With regard to multithreading, with linux distros the libs without "-mt" are sometimes just symlinks to the libs with "-mt" so if that's the case setting Boost_USE_MULTITHREADED to OFF will result in linking the multithreaded libraries.
Answered By - Ryan Maloney Answer Checked By - Cary Denson (WPSolving Admin)