![](/img/trans.png)
[英]Boost 1.66.0 : could not find boost libraries :boost_system, boost_filesystem,boost_thread,boost_date_time
[英]CMake cannot find Boost libraries filestem, thread, date_time, iostreams, system
我正在嘗試從源代碼構建PCL,但是CMake無法找到某些庫。 但是,當我檢查那里的圖書館。 我知道這已經被問了很多,但是我只是從CMake開始,我已經在互聯網上搜索了好幾天,卻找不到可行的解決方案。 我覺得我缺少任何幫助將不勝感激的東西
所以我像其他人建議的那樣在我的CMakeLists.txt中寫了
cmake_minimum_required(VERSION 3.13)
set(Boost_ADDITIONAL_VERSIONS "1.67.0")
set(BOOST_ROOT "C:/local/boost_1_67_0/boost")
set(BOOST_INCLUDEDIR "C:/local/boost_1_67_0/")
set(BOOST_LIBRARYDIR "C:/local/boost_1_67_0/lib64-msvc-14.0")
set (Boost_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.67.0)
但我仍然不斷收到相同的錯誤:
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
Boost version: 1.67.0
Boost include path: C:/local/boost_1_67_0
Could not find the following static Boost libraries:
boost_filesystem
boost_thread
boost_date_time
boost_iostreams
boost_system
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
cmake/pcl_find_boost.cmake:36 (find_package)
CMakeLists.txt:428 (include)
老實說,我會就目前可以嘗試的事情提出任何建議。 如果我可以提供我沒有想到的任何其他有用信息,請隨時發表評論或留言。 謝謝
幾個月前我遇到過同樣的問題。 這解決了我的問題。
find_package(Boost 1.67.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
就像timko.mate所建議的那樣,帶有組件的find_package
是正確的方法。
但是,您應該考慮使用基於目標的API:
target_link_libraries(your_exe PUBLIC Boost::system Boost::filesystem)
另外,要使CMake找到Boost,您應該調整前綴路徑。 通常在項目中調用cmake時完成:
cmake -DMAKE_PREFIX_PATH=c:/local/ ..
這樣,您的cmake文件中就不應包含任何硬編碼的路徑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.