我已经用C++和restbed框架编写了一个API。我已经在我的debian机器上安装了使用vcpkg的restbed。当我发出命令vcpkg list时,将显示restbed。但是,当我将其包含在头文件中并试图编译时,生成将失败。
致命错误:“restbed”文件未找到build #包括restbed
由于我使用的是VSCode,在包含了restbed的头文件中,如果我右键单击它来查看Go to Definition,就会打开一个包含更多文件的restbedC++文件:
#include "corvusoft/restbed/uri.hpp"
#include "corvusoft/restbed/http.hpp"
#include "corvusoft/restbed/rule.hpp"
#include "corvusoft/restbed/byte.hpp"这给我的印象是,已经安装了restbed,但我肯定遗漏了一些东西。
我不熟悉C++,尤其是WebDev。如有任何帮助、建议和澄清,将不胜感激。谢谢。
CMakeLists.txt看起来像:
cmake_minimum_required(VERSION 3.18)
project(API)
add_executable(API
main.cpp
CalcResourceFactory.cpp
CalcService.cpp
CalcServiceSettingsFactory.cpp)
file(GLOB SOURCES "*.cpp")
target_link_libraries(API /home/kali/Applications/vcpkg/installed/x64-linux/include/restbed)
target_include_directories(API PUBLIC ${CMAKE_SOURCE_DIR}/include)
set_property(TARGET API PROPERTY CXX_STANDARD 17)
set(CMAKE_TOOLCHAIN_FILE=/home/kali/Applications/vcpkg/scripts/buildsystems/vcpkg.cmake)虽然我的属性json文件看起来像:
{
"configurations": [
{
"name": "Linux",
"includePath":[
"${workspaceFolder}/projectC++Server**",
"/home/kali/Applications/vcpkg/installed/x64-linux/include",
"projectC++Server/include",
"projectC++Server"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-clang-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}发布于 2021-10-01 09:18:15
vcpkg需要安装阶段(已经完成)和integrate阶段,在此阶段,链接器路径和头路径被添加到VS中。
看这里- https://vcpkg.io/en/getting-started.html
如果您已经完成了vcpkg integrate install,但它仍然不识别这些路径-您将需要添加标题搜索路径使用-I和链接器路径使用-L到您的项目设置。
https://stackoverflow.com/questions/69403138
复制相似问题