我正在尝试将此仅标题库添加到我的项目中:
https://github.com/CPPAlliance/url
我的项目结构:
âââ build
â  âââ build.ninja
â  âââ CMakeCache.txt
â  âââ CMakeFiles
â  â  âââ 3.18.0-rc1
â  â  â  âââ CMakeCCompiler.cmake
â  â  â  âââ CMakeCXXCompiler.cmake
â  â  â  âââ CMakeDetermineCompilerABI_C.bin
â  â  â  âââ CMakeDetermineCompilerABI_CXX.bin
â  â  â  âââ CMakeSystem.cmake
â  â  â  âââ CompilerIdC
â  â  â  âââ CompilerIdCXX
â  â  âââ cmake.check_cache
â  â  âââ CMakeError.log
â  â  âââ CMakeOutput.log
â  â  âââ CMakeTmp
â  â  âââ cmake.verify_globs
â  â  âââ hftbot.dir
â  â  â  âââ build.make
â  â  â  âââ cmake_clean.cmake
â  â  â  âââ CXX.includecache
â  â  â  âââ DependInfo.cmake
â  â  â  âââ depend.internal
â  â  â  âââ depend.make
â  â  â  âââ flags.make
â  â  â  âââ link.txt
â  â  â  âââ progress.make
â  â  â  âââ src
â  â  âââ Makefile2
â  â  âââ Progress
â  â  â  âââ 1
â  â  â  âââ count.txt
â  â  âââ progress.marks
â  â  âââ rules.ninja
â  â  âââ TargetDirectories.txt
â  â  âââ VerifyGlobs.cmake
â  âââ cmake_install.cmake
â  âââ compile_commands.json
â  âââ details.json
â  âââ external
â  â  âââ json
â  â  â  âââ CMakeFiles
â  â  â  âââ cmake_install.cmake
â  â  âââ url
â  â  âââ CMakeFiles
â  â  âââ cmake_install.cmake
â  âââ hftbot
â  âââ Makefile
â  âââ src
â  âââ CMakeFiles
â  â  âââ CMakeDirectoryInformation.cmake
â  â  âââ progress.marks
â  âââ cmake_install.cmake
â  âââ Makefile
âââ build.sh
âââ CMakeLists.txt
âââ configure.sh
âââ details.json
âââ external
â  âââ urlib
â  âââ build
â  â  âââ Jamfile
â  âââ cmake
â  â  âââ config.cmake.in
â  â  âââ toolchains
â  âââ CMakeLists.txt
â  âââ doc
â  â  âââ images
â  â  âââ Jamfile
â  â  âââ javadoc.hpp
â  â  âââ qbk
â  â  âââ README.md
â  â  âââ tools
â  â  âââ xsl
â  âââ extra
â  â  âââ include
â  â  âââ test_main.cpp
â  âââ include
â  â  âââ boost
â  âââ Jamfile
â  âââ LICENSE_1_0.txt
â  âââ meta
â  â  âââ explicit-failures-markup.xml
â  â  âââ libraries.json
â  âââ README.md
â  âââ src
â  â  âââ src.cpp
â  âââ test
â  âââ CMakeLists.txt
â  âââ Jamfile
â  âââ limits
â  âââ unit
â  âââ wpt
âââ run.sh
âââ src
âââ CMakeLists.txt
âââ httpClient.cpp
âââ WebsocketClient.cpp
CMakeLists.txt
在根文件夹中:
cmake_minimum_required(VERSION 3.18.0)
project(hftbot)
find_package(Boost 1.79.0 REQUIRED COMPONENTS system thread filesystem container)
find_package(Threads REQUIRED)
add_subdirectory(src)
include_directories(SYSTEM external/urlib/include)
set(URLIB_DIRECTORY "external/urlib/include")
set(URLIB_HEADERS ${URLIB_DIRECTORY}/boost/url.hpp ${URLIB_DIRECTORY}/boost/url/src.hpp)
set(SOURCES src/httpClient.cpp)
add_executable(${PROJECT_NAME} ${SOURCES} ${URLIB_HEADERS})
target_include_directories(${PROJECT_NAME} PRIVATE ${URLIB_DIRECTORY})
如你所见,我曾经
target_include_directories()
将头文件包含到我的项目中。
但这里似乎有点不对劲。
#include <boost/url.hpp>
#include <boost/url/src.hpp>
当我尝试包含这个时,它向我显示了构建错误:
/usr/local/bin/cmake -S/home/user/Desktop/HFTBOT -B/home/user/Desktop/HFTBOT/build --check-build-system CMakeFiles/Makefile.cmake 0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Desktop/HFTBOT/build
/usr/local/bin/cmake -E cmake_progress_start /home/user/Desktop/HFTBOT/build/CMakeFiles /home/user/Desktop/HFTBOT/build//CMakeFiles/progress.marks
make -s -f CMakeFiles/Makefile2 all
Scanning dependencies of target hftbot
CMake Error: Directory Information file not found
[ 50%] Building CXX object CMakeFiles/hftbot.dir/src/httpClient.cpp.o
/home/user/Desktop/HFTBOT/src/httpClient.cpp:11:10: fatal error: boost/url/src.hpp: No such file or directory
11 | #include "boost/url/src.hpp"
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/hftbot.dir/build.make:83: CMakeFiles/hftbot.dir/src/httpClient.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:116: CMakeFiles/hftbot.dir/all] Error 2
make: *** [Makefile:104: all] Error 2
我有一种感觉,是因为可执行文件的位置导致了这个错误吗?