1

I have been working on a library in C++ and have run into a bit of difficulty trying to integrate boost into my project. I kept the message that boost could not be found, but on the other hand, my fellow developer using Arch had no issues.

We figured out that this is because Linux Mint (at least with the libboost-all-dev package) installs the libraries to /usr/lib/x86_64-linux-gnu which is not searched by the FindBoost module. We fixed this by creating symbolic links:

ln -s /usr/lib/x86_64-linux-gnu/libboost* /usr/lib/ 

What I want to know: is there a better (more acceptable) way of fixing this because when I compile major projects, I do not run into this problem.

Here is CMakeLists.txt (with some omissions)

cmake_minimum_required(VERSION 2.8) project(testlibrary CXX) set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED OFF) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.55.0 COMPONENTS unit_test_framework thread log REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) add_library(testlibrary STATIC ${SOURCE_MAIN}) target_link_libraries(testlibrary ${Boost_LIBRARIES}) 
1
  • What specific version of CMake are you using? Commented Apr 22, 2015 at 23:49

1 Answer 1

2

You can set the hint BOOST_LIBRARYDIR:

set(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu") find_package(Boost 1.55.0 COMPONENTS unit_test_framework thread log REQUIRED) 

Alternative, you can set this when running CMake like this:

cmake -DBOOST_LIBRARYDIR="/usr/lib/x86_64-linux-gnu" <project_root> 

If you just run:

cmake <project_root> 

then FindBoost.cmake will look in the usual spots for your boost libaries.

See the documentation of FindBoost.cmake for your CMake version here.

Sign up to request clarification or add additional context in comments.

7 Comments

OK, but would that work on my partner's computer, or would they have to remove that on their end? Theirs is installed just to /user/lib/
The best way to handle that is to have a project level option that lets you set BOOST_LIBRARYDIR.
do you mean set(BOOST_LIB_DIR /usr/lib/x86_64-linux-gnu)
Disregard my comment above, there's no need for a project level option. Variables set on the command line are automatically used in the find modules.
No, BOOST_LIB_DIR is not used at all by the find module. You have to set BOOST_LIBRARYDIR. If you inspect the source you'll see what's going on.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.