我想在我的新C++項目中安裝和使用Boost 1.60.0。 (我使用Ubuntu,CLion和CMake開發和構建)。CMake無法找到boost_asio
我做了什麼?
- 我從網站上的link provided下載了Boost。
- 提取到
/devenv/boost160
(/devenv/boost160
是根,以後我改名爲原來的文件夾) - 我跑
./bootstrap.sh
從/devenv/boost160
(一切正常;根據自己的official documentation,不帶參數運行此,需要輸出爲/usr/local
),它進展順利。 - 我創建了一個CLION項目並將以下內容添加到
CMakeLists.txt
。
set(BOOST_ROOT /usr/local/include/boost)
set(BOOST_LIBRARYDIR /usr/local/lib)
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_DEBUG ON)
find_package(Boost 1.60.0 REQUIRED COMPONENTS asio date_time)
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()
- 我跑了克利翁的建立命令,我得到了下面的輸出,基本上說,這是無法找到
boost_asio
。
/devenv/clion-1.1/bin/cmake/bin/cmake --build /home/victor/.clion11/system/cmake/generated/50ae3d2f/50ae3d2f/Debug0 --target all -- -j 8
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:549 ] _boost_TEST_VERSIONS =
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:551 ] Boost_USE_MULTITHREADED = TRUE
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:553 ] Boost_USE_STATIC_LIBS = ON
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:555 ] Boost_USE_STATIC_RUNTIME = ON
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:557 ] Boost_ADDITIONAL_VERSIONS =
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:559 ] Boost_NO_SYSTEM_PATHS =
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:611 ] Declared as CMake or Environmental Variables:
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:613 ] BOOST_ROOT = /usr/local/include/boost
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:615 ] BOOST_INCLUDEDIR =
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:617 ] BOOST_LIBRARYDIR = /usr/local/lib
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:619 ] _boost_TEST_VERSIONS =
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:712 ] location of version.hpp: /usr/local/include/boost/version.hpp
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:736 ] version.hpp reveals boost 1.60.0
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:822 ] guessed _boost_COMPILER = -gcc48
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:832 ] _boost_MULTITHREADED = -mt
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:875 ] _boost_RELEASE_ABI_TAG = -s
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:877 ] _boost_DEBUG_ABI_TAG = -sd
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:931 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/lib/x86_64-linux-gnu;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH_boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/lib/x86_64-linux-gnu;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1043 ] Searching for ASIO_LIBRARY_RELEASE: boost_asio-gcc48-mt-s-1_60;boost_asio-gcc48-mt-s;boost_asio-mt-s-1_60;boost_asio-mt-s;boost_asio
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:343 ] Boost_LIBRARY_DIR_RELEASE = /usr/lib/x86_64-linux-gnu _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/lib/x86_64-linux-gnu;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1085 ] Searching for ASIO_LIBRARY_DEBUG: boost_asio-gcc48-mt-sd-1_60;boost_asio-gcc48-mt-sd;boost_asio-mt-sd-1_60;boost_asio-mt-sd;boost_asio-mt;boost_asio
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:343 ] Boost_LIBRARY_DIR_DEBUG = /usr/lib/x86_64-linux-gnu _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/lib/x86_64-linux-gnu;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1043 ] Searching for DATE_TIME_LIBRARY_RELEASE: boost_date_time-gcc48-mt-s-1_60;boost_date_time-gcc48-mt-s;boost_date_time-mt-s-1_60;boost_date_time-mt-s;boost_date_time
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:343 ] Boost_LIBRARY_DIR_RELEASE = /usr/lib/x86_64-linux-gnu _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/lib/x86_64-linux-gnu;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1085 ] Searching for DATE_TIME_LIBRARY_DEBUG: boost_date_time-gcc48-mt-sd-1_60;boost_date_time-gcc48-mt-sd;boost_date_time-mt-sd-1_60;boost_date_time-mt-sd;boost_date_time-mt;boost_date_time
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:343 ] Boost_LIBRARY_DIR_DEBUG = /usr/lib/x86_64-linux-gnu _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/lib/x86_64-linux-gnu;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1151 ] Boost_FOUND = 1
CMake Error at /devenv/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1245 (message):
Unable to find the requested Boost libraries.
Boost version: 1.60.0
Boost include path: /usr/local/include
Could not find the following static Boost libraries:
boost_asio
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):
CMakeLists.txt:12 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/victor/.clion11/system/cmake/generated/50ae3d2f/50ae3d2f/Debug0/CMakeFiles/CMakeOutput.log".
make: *** [cmake_check_build_system] Error 1
如何使用升壓1.60.0在我的項目給我的配置?謝謝!
感謝您的快速響應。我試過這個,但我仍然遇到錯誤:https://dpaste.de/TyWV – Victor
好的,你是一個天才!謝謝! – Victor