0

iam trying to build the boost library and use cmake to build my application. Building and installing boost was just following the Getting Started Guide and changing the prefix to /usr

./bootstrap.sh --prefix=/usr
./b2 install

As result i have now in /usr/lib:

libboost_atomic.a
libboost_atomic.so
libboost_atomic.so.1.64.0
...

And in /usr/include/boost

aligned_storage.hpp
align.hpp
...

My CMakeLists.txt

cmake_minimum_required (VERSION 2.6)
project (NewMediaServer)
# Set the output folder where your program will be created
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})    
# set the folder of the binarys
include_directories(${PROJECT_BINARY_DIR}/src)
# find all packages which we are depending on
find_package(Boost 1.64 REQUIRED)
# name the main cpp and the executable
add_executable(mediaserver src/MediaServer.cpp)
# configure compile and linking options
target_compile_options(mediaserver PUBLIC -std=c++11 -Wall)
target_link_libraries(mediaserver PUBLIC -pthread -lboost_system -lboost_log -lboost_log_setup -lboost_thread -lboost_date_time -lboost_filesystem)

When i run make everything works fine, but as soon as iam running the binary iam getting the following error ....

./bin/mediaserver: error while loading shared libraries: libboost_system.so.1.64.0: cannot open shared object file: No such file or directory

Really appreciate any help! I'am still new to Cmake and Boost so be gentle ;) Thanks in advance

Hestalon
  • 31
  • 3
  • 1
    CMake version 2.6 and brand-new Boost 1.64: Are you serious? Have a look at https://stackoverflow.com/a/42124857/2799037 – usr1234567 Aug 09 '17 at 14:32
  • 2
    @usr1234567 While the required version could be set to something more appropriate, it doesn't necessarily mean that the OP uses 2.6. – Dan Mašek Aug 09 '17 at 16:48
  • 1
    `CMAKE_BINARY_DIR` should be treated as **readonly** variable. Never set it. Why use [find_package(Boost)](https://cmake.org/cmake/help/v3.0/module/FindBoost.html), and do not use **variables** it defines for linking with Boost? – Tsyvarev Aug 09 '17 at 17:38
  • @usr1234567 Thanks for the suggestion, was using cmake 2.8 before from CentOS repo. Switched to cmake 3.9, needed to set a link to the binaries default located in /usr/local/bin/cmake. Also builded boost with default prefix. Now it works. Also changed my project like @Tsyvarev suggested to not override the `CMAKE_BINARY_DIR`. Anytime later i will try it again with prefix building but for now iam fine. Thanks! – Hestalon Aug 10 '17 at 07:03

1 Answers1

0

@usr1234567 Thanks for the suggestion, was using cmake 2.8 before from CentOS repo. Switched to cmake 3.9, needed to set a link to the binaries default located in /usr/local/bin/cmake. Also builded boost with default prefix. Now it works. Also changed my project like @Tsyvarev suggested to not override the CMAKE_BINARY_DIR. Anytime later i will try it again with prefix building but for now iam fine. Thanks!

Hestalon
  • 31
  • 3