0

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

代码包括

错误信息

我对此还很陌生,所以我包含了它带来的错误的屏幕截图以及它在代码中的提及方式,以便希望提供一些关于正在发生的事情的见解。随时询问是否需要更多信息。

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
            }
        }
    ]
}
4

1 回答 1

2

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

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

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

于 2018-08-06T12:42:32.793 回答