首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >构建和链接Boost

构建和链接Boost
EN

Stack Overflow用户
提问于 2017-08-09 22:30:52
回答 1查看 209关注 0票数 0

我正在尝试构建boost库并使用cmake来构建我的应用程序。构建和安装boost只是遵循Getting Started Guide并将前缀更改为/usr

代码语言:javascript
复制
./bootstrap.sh --prefix=/usr
./b2 install

因此,我现在在/usr/lib中:

代码语言:javascript
复制
libboost_atomic.a
libboost_atomic.so
libboost_atomic.so.1.64.0
...

和/usr/include/boost中

代码语言:javascript
复制
aligned_storage.hpp
align.hpp
...

我的CMakeLists.txt

代码语言:javascript
复制
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时,一切都很好,但只要我运行二进制文件,我就会得到以下错误...

代码语言:javascript
复制
./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还是新手,所以要温柔点;)提前谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-10 15:06:30

@usr1234567感谢您的建议,我之前正在使用来自CentOS repo的cmake 2.8。切换到cmake 3.9,需要设置指向位于/usr/local/bin/cmake中的默认二进制文件的链接。还构建了带有默认前缀的boost。现在它起作用了。我还修改了我的项目,比如@Tsyvarev建议不要覆盖CMAKE_BINARY_DIR。任何时候以后我会再次尝试前缀构建,但现在我很好。谢谢!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45593585

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档