我通過這個添加上去:CMake的:未定義參考Boost庫
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 VS BOOST_LIBRARIES),但它的確定。
我使用package boost-devel在Fedora中安裝了boost。
是什麼'$ {Boost_LIBRARIES}'的內容? – Hayt
它應該是靜態提升lib的路徑(https://cmake.org/cmake/help/v3.0/module/FindBoost.html) – Seraph
沒有「一個」靜態提升lib。你能打印它,而不是它「應該」? – Hayt