2016-09-15 1 views
1

나는이를 통해 부스트를 추가 :CMake는 : 라이브러리 높일 참조를 정의되지 않은

set(Boost_USE_STATIC_LIBS  ON) 
set(Boost_USE_MULTITHREADED  ON) 
set(Boost_USE_STATIC_RUNTIME OFF) 
find_package(Boost REQUIRED) 
include_directories(${Boost_INCLUDE_DIR}) 

project(APP C CXX) 
add_executable(APP src.cpp) 
target_link_libraries(APP ${Boost_LIBRARIES}) 

을 그리고 소스를 컴파일 할 때, 내가 가지고 :

demo.cpp:(.text+0x3d3): undefined reference to `boost::system::generic_category()' 

나는 (BOOST_LIBRARIES 대 Boost_LIBRARIES) 맞춤법을 검사하지만 괜찮아요 .

패키지 boost-devel을 사용하여 Fedora에 boost를 설치했습니다.

+3

'$ {Boost_LIBRARIES}'의 내용은 무엇인가 :

find_package(Boost REQUIRED COMPONENTS system) 

또한 수입 목표를 사용해야합니까? – Hayt

+0

정적 향상 라이브러리 (https://cmake.org/cmake/help/v3.0/module/FindBoost.html) – Seraph

+2

에 대한 경로 여야합니다. "하나"정적 향상 라이브러리가 없습니다. 그리고 당신이 그것을 인쇄해야하고 그것이 "있어야"하는 것이 아닌가? – Hayt

답변

4

source code에서 보면 find_package에 전달 된 구성 요소 목록에 따라 Boost_LIBRARIES이 채워집니다. 시도 :

set(Boost_USE_STATIC_LIBS  ON) 
set(Boost_USE_MULTITHREADED  ON) 
set(Boost_USE_STATIC_RUNTIME OFF) 
find_package(Boost REQUIRED COMPONENTS system) 

# the call to include_directories is now useless: 
# the Boost::system imported target used below 
# embeds the include directories 

project(APP C CXX) 
add_executable(APP src.cpp) 
target_link_libraries(APP Boost::system) 
+0

cmake가 boost_system을 찾지 못했습니다 ... 부스트 시스템을 설치했지만 boost-system-dev가 존재하지 않습니다 – Seraph

+3

다른 사람들을 위해서만 : 링크 구문'Boost :: '는 자동으로 대상 디렉토리에 include 디렉토리를 추가합니다. 그래서 여기에'include_directories'가 "쓸데없는"이유입니다. – Hayt

+0

@Seraph는 "-dev"버전이 필요합니다. – Hayt

관련 문제