无法在带有 conan 的 cmake 中找到请求的 Boost 库
Unable to find the requested Boost libraries in cmake with conan
我在使用 Unix 系统中柯南依赖项的 c++ 中的 boost 库使用 cmake 进行编译时遇到问题 (Ubuntu)
sfml 库已在项目中实现并运行,但 boost 库无法运行并显示此消息:
CMake Error at /usr/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:13 (find_package)
这是我的conanfile.txt
[requires]
sfml/2.5.1@bincrafters/stable
boost/1.69.0@conan/stable
[options]
sfml:graphics=True
sfml:window=True
sfml:audio=True
sfml:network=False
[generators]
cmake
这是我的 CMakeLists.txt
# Minimum version of cmake
cmake_minimum_required(VERSION 3.10)
# Setting the project
project(CPP_rtype_2019 CXX)
include(build/conanbuildinfo.cmake)
# Dependencies Sfml
find_package(SFML 2.5.1 EXACT REQUIRED COMPONENTS system window graphics audio)
find_package(Threads REQUIRED)
# Dependencies Boost
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11)
# Added all .hpp
include_directories(client/include)
include_directories(server/include)
# Added all .cpp
add_executable(r-type_client client/src/Actor.cpp client/src/Character.cpp client/src/Ennemy.cpp client/src/Interface.cpp client/src/Pown.cpp client/src/Projectile.cpp)
add_executable(r-type_server server/src/GameEngine.cpp)
# Added dependencies to compilation
target_link_libraries(r-type_client PRIVATE sfml-audio sfml-system sfml-graphics)
target_link_libraries(r-type_server PRIVATE Boost::thread Boost::system Boost::filesystem)
我尝试了很多解决方案,但没有一个有效。欢迎所有解决方案或提示,谢谢!
我想你忘了在 CMakeLists.txt
中添加 conan_basic_setup()
查看# Setting the project
块
# Minimum version of cmake
cmake_minimum_required(VERSION 3.10)
# Setting the project
project(CPP_rtype_2019 CXX)
include(build/conanbuildinfo.cmake)
conan_basic_setup()
# Dependencies Sfml
find_package(SFML 2.5.1 EXACT REQUIRED COMPONENTS system window graphics audio)
find_package(Threads REQUIRED)
# Dependencies Boost
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11)
# Added all .hpp
include_directories(client/include)
include_directories(server/include)
# Added all .cpp
add_executable(r-type_client client/src/Actor.cpp client/src/Character.cpp client/src/Ennemy.cpp client/src/Interface.cpp client/src/Pown.cpp client/src/Projectile.cpp)
add_executable(r-type_server server/src/GameEngine.cpp)
# Added dependencies to compilation
target_link_libraries(r-type_client PRIVATE sfml-audio sfml-system sfml-graphics)
target_link_libraries(r-type_server PRIVATE Boost::thread Boost::system Boost::filesystem)
这是自述文件中正确使用的示例 https://github.com/conan-io/cmake-conan
不需要conanfile.txt,已经生成了
cmake_minimum_required(VERSION 3.5)
project(FormatOutput CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484
TLS_VERIFY ON)
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_configure(REQUIRES
boost/1.69.0
GENERATORS cmake_find_package)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conancenter
SETTINGS ${settings})
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
add_executable(main main.cpp)
target_link_libraries(main
Boost::thread
Boost::system
Boost::filesystem)
我在使用 Unix 系统中柯南依赖项的 c++ 中的 boost 库使用 cmake 进行编译时遇到问题 (Ubuntu)
sfml 库已在项目中实现并运行,但 boost 库无法运行并显示此消息:
CMake Error at /usr/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:13 (find_package)
这是我的conanfile.txt
[requires]
sfml/2.5.1@bincrafters/stable
boost/1.69.0@conan/stable
[options]
sfml:graphics=True
sfml:window=True
sfml:audio=True
sfml:network=False
[generators]
cmake
这是我的 CMakeLists.txt
# Minimum version of cmake
cmake_minimum_required(VERSION 3.10)
# Setting the project
project(CPP_rtype_2019 CXX)
include(build/conanbuildinfo.cmake)
# Dependencies Sfml
find_package(SFML 2.5.1 EXACT REQUIRED COMPONENTS system window graphics audio)
find_package(Threads REQUIRED)
# Dependencies Boost
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11)
# Added all .hpp
include_directories(client/include)
include_directories(server/include)
# Added all .cpp
add_executable(r-type_client client/src/Actor.cpp client/src/Character.cpp client/src/Ennemy.cpp client/src/Interface.cpp client/src/Pown.cpp client/src/Projectile.cpp)
add_executable(r-type_server server/src/GameEngine.cpp)
# Added dependencies to compilation
target_link_libraries(r-type_client PRIVATE sfml-audio sfml-system sfml-graphics)
target_link_libraries(r-type_server PRIVATE Boost::thread Boost::system Boost::filesystem)
我尝试了很多解决方案,但没有一个有效。欢迎所有解决方案或提示,谢谢!
我想你忘了在 CMakeLists.txt
中添加conan_basic_setup()
查看# Setting the project
块
# Minimum version of cmake
cmake_minimum_required(VERSION 3.10)
# Setting the project
project(CPP_rtype_2019 CXX)
include(build/conanbuildinfo.cmake)
conan_basic_setup()
# Dependencies Sfml
find_package(SFML 2.5.1 EXACT REQUIRED COMPONENTS system window graphics audio)
find_package(Threads REQUIRED)
# Dependencies Boost
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11)
# Added all .hpp
include_directories(client/include)
include_directories(server/include)
# Added all .cpp
add_executable(r-type_client client/src/Actor.cpp client/src/Character.cpp client/src/Ennemy.cpp client/src/Interface.cpp client/src/Pown.cpp client/src/Projectile.cpp)
add_executable(r-type_server server/src/GameEngine.cpp)
# Added dependencies to compilation
target_link_libraries(r-type_client PRIVATE sfml-audio sfml-system sfml-graphics)
target_link_libraries(r-type_server PRIVATE Boost::thread Boost::system Boost::filesystem)
这是自述文件中正确使用的示例 https://github.com/conan-io/cmake-conan
不需要conanfile.txt,已经生成了
cmake_minimum_required(VERSION 3.5)
project(FormatOutput CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484
TLS_VERIFY ON)
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_configure(REQUIRES
boost/1.69.0
GENERATORS cmake_find_package)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conancenter
SETTINGS ${settings})
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
add_executable(main main.cpp)
target_link_libraries(main
Boost::thread
Boost::system
Boost::filesystem)