admin管理员组

文章数量:1387461

Have library glfw3 that needs importing into imgui demo project. I know how to configure the library paths in the .vscode/c_cpp_properties.json file and the intellisense feature brings me right to the library if I search the definition just when it compiles it throws the error.fatal error: GLFW/glfw3.h: No such file or directory. I have already spent hours trying every solution I could find and nothing has worked / gotten me past this error. (This is a Linux system, using g++ (11.4.0) compiler but have tried others too.)

.vscode/c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/home/brandon/Coding/cpp_install/"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++-11",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cpptools"
        }
    ],
    "version": 4
}

.vscode/tasks.json:

{
    "tasks": [
      {
        "type": "cppbuild",
        "label": "Build Debug",
        "command": "g++",
        "args": [
          "${workspaceRoot}\\main.cpp",
          "-I /home/brandon/Coding/cpp_install/GLFW",
          "-L /home/brandon/Coding/cpp_install/",
          "-lglfw",
          "-g",
          "-o",
          "${workspaceRoot}\\main"
        ],
      }
    ],
    "version": "2.0.0"
  }

EDIT: I use the vscode code runner to do the automatic compile.

INFORMATION:

glfw file path: /home/brandon/Coding/cpp_install/GLFW/

I do believe that the build process is not using tasks.json and I am not really sure how to properly compile without the code runner.

What is the best route to compile outside of vscode (or easily inside) with still using vscode as my main editor.

Have library glfw3 that needs importing into imgui demo project. I know how to configure the library paths in the .vscode/c_cpp_properties.json file and the intellisense feature brings me right to the library if I search the definition just when it compiles it throws the error.fatal error: GLFW/glfw3.h: No such file or directory. I have already spent hours trying every solution I could find and nothing has worked / gotten me past this error. (This is a Linux system, using g++ (11.4.0) compiler but have tried others too.)

.vscode/c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/home/brandon/Coding/cpp_install/"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++-11",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cpptools"
        }
    ],
    "version": 4
}

.vscode/tasks.json:

{
    "tasks": [
      {
        "type": "cppbuild",
        "label": "Build Debug",
        "command": "g++",
        "args": [
          "${workspaceRoot}\\main.cpp",
          "-I /home/brandon/Coding/cpp_install/GLFW",
          "-L /home/brandon/Coding/cpp_install/",
          "-lglfw",
          "-g",
          "-o",
          "${workspaceRoot}\\main"
        ],
      }
    ],
    "version": "2.0.0"
  }

EDIT: I use the vscode code runner to do the automatic compile.

INFORMATION:

glfw file path: /home/brandon/Coding/cpp_install/GLFW/

I do believe that the build process is not using tasks.json and I am not really sure how to properly compile without the code runner.

What is the best route to compile outside of vscode (or easily inside) with still using vscode as my main editor.

Share Improve this question edited Mar 17 at 18:13 A-Person-Who-Codes asked Mar 17 at 6:50 A-Person-Who-CodesA-Person-Who-Codes 95 bronze badges 10
  • Use a proper build system and fet the rubbish C/C++ code runner. – Botje Commented Mar 17 at 8:42
  • What would be the best route to make a build system and getting away from the vscode code runner? – A-Person-Who-Codes Commented Mar 17 at 13:55
  • to have a comment adressed to specific user, you must prepend a comment with '@username'. this way, user gets notified about your comment. – iam_ai_copy-paste Commented Mar 17 at 14:14
  • i use 'makefile's as a build system. i use 'make' with 'vscode'. i find it quickier to configure and faster to use. the vscode json mantra is another thing to learn and occupy a place in my head. – iam_ai_copy-paste Commented Mar 17 at 14:18
  • @Botje What would the best system to do this, makefile? – A-Person-Who-Codes Commented Mar 17 at 17:34
 |  Show 5 more comments

1 Answer 1

Reset to default 0

In tasks.json change

"-I /home/brandon/Coding/cpp_install/GLFW"

to

"-I /home/brandon/Coding/cpp_install"

As you said yourself you have the correct include path in c_cpp_properties.json so I'm not sure why you didn't put the same path in tasks.json.

BTW the -L option in tasks.json also looks wrong, but that's a different issue.

本文标签: visual studio codeConfusion on configuring c library paths in vscodeg compilerStack Overflow