Reputation: 164
I'm currently having an issue to where visual studio code is not recognizing the include of the json.hpp file no matter what I do in the IDE, I don't admittedly know if the issue is being caused by the IDE, my own silly mistake, or by the way the json library is installed. I used linuxbrew on Ubuntu Server 16.04 LTS in order to install it, and I have the latest stable version. I'm using the g++ compiler (version 5.5 I believe)
I'm still new to this, so I included screenshots of the error it brings up along with how it is mentioned in the code in order to hopefully provide some insight as to what is going on. Feel free to ask if more information is needed.
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
}
tasks.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
}
}
]
}
Upvotes: 0
Views: 6014
Reputation: 36379
You need to add the include path to your gcc command line, for example:
....
"args": [
"-g", "src/calibration.cpp",
"-o", "build/calibration.out",
"-std=c++11",
"-I/home/linuxbrew/.linuxbrew/Cellar/nlohmann_json/3.1.2/include",
....
Make sure to save the file before building.
Upvotes: 2