我正在尝试构建boost库并使用cmake来构建我的应用程序。构建和安装boost只是遵循Getting Started Guide并将前缀更改为/usr
./bootstrap.sh --prefix=/usr
./b2 install因此,我现在在/usr/lib中:
libboost_atomic.a
libboost_atomic.so
libboost_atomic.so.1.64.0
...和/usr/include/boost中
aligned_storage.hpp
align.hpp
...我的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)当我运行make everything时,一切都很好,但只要我运行二进制文件,我就会得到以下错误...
./bin/mediaserver: error while loading shared libraries: libboost_system.so.1.64.0: cannot open shared object file: No such file or directory真的很感谢大家的帮助!我对Cmake和Boost还是新手,所以要温柔点;)提前谢谢
发布于 2017-08-10 15:06:30
@usr1234567感谢您的建议,我之前正在使用来自CentOS repo的cmake 2.8。切换到cmake 3.9,需要设置指向位于/usr/local/bin/cmake中的默认二进制文件的链接。还构建了带有默认前缀的boost。现在它起作用了。我还修改了我的项目,比如@Tsyvarev建议不要覆盖CMAKE_BINARY_DIR。任何时候以后我会再次尝试前缀构建,但现在我很好。谢谢!
https://stackoverflow.com/questions/45593585
复制相似问题