gpt4 book ai didi

c++ - nlohmann JSON C++ 包含问题

转载 作者:行者123 更新时间:2023-11-28 04:35:05 33 4
gpt4 key购买 nike

我目前遇到一个问题,无论我在 IDE 中做什么,visual studio 代码都无法识别包含的 json.hpp 文件,我不知道问题是否是由 IDE 引起的,我自己的愚蠢错误,还是顺便安装了json库。我在 Ubuntu Server 16.04 LTS 上使用了 linuxbrew 来安装它,我有最新的稳定版本。我正在使用 g++ 编译器(我相信是 5.5 版)

Code Include

Error Message

我对此还是个新手,所以我提供了错误的屏幕截图以及它在代码中的提及方式,希望能提供一些关于正在发生的事情的见解。如果需要更多信息,请随时询问。

c_cpp_properties.json:

{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"opt/opencv/release/include",
"/home/linuxbrew/.linuxbrew/Cellar/nlohmann_json/3.1.2/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

任务.json:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build app",
"type": "shell",
"command": "g++",
"args": [
"-g", "src/calibration.cpp",
"-o", "build/calibration.out",
"-std=c++11",
"-L/usr/local/Cellar/opencv/3.4.1_5/lib",
"-lopencv_stitching",
"-lopencv_superres",
"-lopencv_videostab",
"-lopencv_aruco",
"-lopencv_bgsegm",
"-lopencv_bioinspired",
"-lopencv_ccalib",
"-lopencv_dnn_objdetect",
"-lopencv_dpm",
"-lopencv_face",
"-lopencv_photo",
"-lopencv_fuzzy",
"-lopencv_hfs",
"-lopencv_img_hash",
"-lopencv_line_descriptor",
"-lopencv_optflow",
"-lopencv_reg",
"-lopencv_rgbd",
"-lopencv_saliency",
"-lopencv_stereo",
"-lopencv_structured_light",
"-lopencv_phase_unwrapping",
"-lopencv_surface_matching",
"-lopencv_tracking",
"-lopencv_datasets",
"-lopencv_dnn",
"-lopencv_plot",
"-lopencv_xfeatures2d",
"-lopencv_shape",
"-lopencv_video",
"-lopencv_ml",
"-lopencv_ximgproc",
"-lopencv_calib3d",
"-lopencv_features2d",
"-lopencv_highgui",
"-lopencv_videoio",
"-lopencv_flann",
"-lopencv_xobjdetect",
"-lopencv_imgcodecs",
"-lopencv_objdetect",
"-lopencv_xphoto",
"-lopencv_imgproc",
"-lopencv_core"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

最佳答案

您需要将包含路径添加到您的 gcc 命令行,例如:

....
"args": [
"-g", "src/calibration.cpp",
"-o", "build/calibration.out",
"-std=c++11",
"-I/home/linuxbrew/.linuxbrew/Cellar/nlohmann_json/3.1.2/include",
....

确保在构建之前保存文件。

关于c++ - nlohmann JSON C++ 包含问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51707031/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com