我有一个问题需要在Unix系统(Ubuntu)中使用boost库从conan依赖项中编译cmake方式的c++代码。SFML库已经实现并在项目中工作,但是boost库无法运行,并显示以下消息:
这是我的CMakeLists.txt文件。
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)
我尝试了很多解决方案,但都无效。欢迎提供任何解决方案或提示,谢谢!