-1

I am running Ubuntu 18.04.1 and trying to compile the file DeviceInfo.cpp which is located in ~/Desktop/Cpp/me_surfaceControl/src. Many header files are required, including GenicamSystem.h which is located in ~/Desktop/surfaceControl/C++/include.

I added the header file locations to the IntelliSense Configurations as well as to c_cpp_properties.json.

Even though the locations are specified, I am getting the error /home/nitish/Desktop/Cpp/me_surfaceControl/src/DeviceInfo.cpp:10:10: fatal error: GenicamSystem.h: No such file or directory #include <GenicamSystem.h> Error message, code, and vscode configurations

I have tried to force include the header file in the advanced configurations, with no outcome. I also tried to include the header like this: #include <include/GenicamSystem>, which was also useless.

This how the tasks.json file looks like:

   {
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "Build C++ using g++ 7",
            "command": "/usr/bin/g++-7",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "-Wall",
                "-I~/Desktop/surfaceControl/C++/include",
                "-I~/Desktop/surfaceControl/C/include",
                "-I~/desktop/surfaceControl/MEDataTypes/include",
                "-I~/Desktop/surfaceControl/MEPointCloud/include"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: /usr/bin/g++-7"
        }
    ]
}
Saad
  • 1
  • 2
  • Show the text of your tasks.json. That file sets the include paths for building. – drescherjm May 09 '22 at 11:39
  • I just added the tasks.json content to the post. I was not able to understand the "args" section; it would be great if you could briefly explain it as well. – Saad May 09 '22 at 13:41
  • `-IFolder` adds an include directory. You did not do that so during the build your compiler only looks in the system locations and the same folder as the cpp file. The build settings are completely independent of the c_cpp_properties.json settings which are for the IDE only. – drescherjm May 09 '22 at 13:45
  • This question helps you with your compiler arguments: [https://stackoverflow.com/questions/6141147/how-do-i-include-a-path-to-libraries-in-g](https://stackoverflow.com/questions/6141147/how-do-i-include-a-path-to-libraries-in-g) – drescherjm May 09 '22 at 13:46
  • I modified the tasks.json file accordingly, and I am still getting the same error. You can check the modifications I did in the post. – Saad May 09 '22 at 14:03
  • Thanks for the help, I just needed to figure out the correct syntax to use. The paths need to be specified like this: "-I", "~/Desktop/surfaceControl/C++/include", "-I", "~/Desktop/surfaceControl/C/include", .... . – Saad May 09 '22 at 14:55

0 Answers0