2017-08-09 50 views
0

iam試圖構建boost庫並使用cmake構建我的應用程序。 構建和安裝升壓只是跟隨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中/升壓

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) 

當我運行使一切工作正常,但只要IAM運行二進制IAM收到以下錯誤....

​​

非常感謝所有幫助!我'還是新的CMake和升壓所以要溫柔;提前

+1

CMake 2.6版和全新的Boost 1.64:你認真嗎?看看https://stackoverflow.com/a/42124857/2799037 – usr1234567

+2

@ usr1234567儘管所需的版本可以設置爲更合適的內容,但並不一定意味着OP使用2.6。 –

+1

'CMAKE_BINARY_DIR'應被視爲**只讀**變量。永遠不要設置它。爲什麼要使用[find_package(Boost)](https://cmake.org/cmake/help/v3.0/module/FindBoost.html),並且不要使用它定義的用於鏈接Boost的**變量? – Tsyvarev

回答

0

) 感謝@ usr1234567感謝您的建議,使用CentOS的從回購前的cmake 2.8。切換到cmake 3.9,需要設置鏈接到位於/ usr/local/bin/cmake中的二進制文件。還使用默認前綴構建boost。現在它可以工作。還改變了我的項目像@Tsyvarev建議不要覆蓋CMAKE_BINARY_DIR。任何時候以後我會再嘗試用前綴建立,但現在我很好。謝謝!