[英]CMake with Boost could not find static libraries
我在使用CMake和Boost庫時遇到了一些麻煩。 我有以下錯誤:
CMake Error at C:/Program Files (x86)/CMake
2.8/share/cmake-2.8/Modules/FindBoost.cmake:1111 (message): Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: C:/local/boost_1_55_0
Could not find the following static Boost libraries:
boost_system
boost_date_time
boost_regex
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR
to the directory containing Boost libraries or BOOST_ROOT to the
location of Boost. Call Stack (most recent call first):
CMakeLists.txt:10 (find_package)
-- Configuring incomplete, errors occurred!
我在我的CMakeLists.txt中做了我在互聯網上找到的所有內容,但它不起作用,我不明白。 我正在使用Windows 8和Visual Studio 12,並且Boost安裝在默認目錄中。 (C:/本地/ boost_1_55_0)
這是我的CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
project (server)
set(BOOST_ROOT "c:\\local\\boost_1_55_0")
set (Boost_USE_STATIC_LIBS ON) set (Boost_MULTITHREADED ON) set
(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.55 COMPONENTS system date_time regex REQUIRED)
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
set(SRCS main.cpp Server.cpp Client.cpp)
set(HEADERS Server.h Client.h)
include_directories(${Boost_INCLUDE_DIR})
add_executable(babel_server ${SRCS} ${HEADERS})
target_link_libraries(babel_server ${Boost_LIBRARIES})
有人可以幫我嗎?
謝謝
我猜你的編譯庫不在你的BOOST_ROOT / lib /文件夾中。 在這種情況下,您需要設置lib文件夾目錄路徑。
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib/)
要么
set(BOOST_LIBRARYDIR path/to/your/lib/folder)
我有同樣的問題
通過使用命令解決
bjam install --prefix="<your boost install folder>" --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi
我在vs2017的Windows 10上,我只是添加:
"set(Boost_LIB_PREFIX "lib")
set(_boost_RELEASE_ABI_TAG ".lib")"
之前
"unset(_boost_RELEASE_NAMES)"
在FindBoost.cmake
文件中解決了我的問題!
將這兩行放在Findboost.cmake
可以解決問題。 我在windows 10
使用visual studio 17
。
set(Boost_LIB_PREFIX "lib")
set(_boost_RELEASE_ABI_TAG ".lib")
如果我是正確的,FindBoost正在搜索沒有.lib的文件,但庫最終會有.lib。
確保您為發電機選擇了合適的平台。
例如,如果你的Boost是64位且CMake的生成器設置為Win32(在Windows上是默認的),它將無法找到庫。 只要您第一次嘗試配置項目時就會設置此項,您可以通過刪除緩存來重置它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.