【问题标题】:cannot open source file "glibconfig.h" (dependency of "gtk/gtk.h") in Studio Code无法在 Studio Code 中打开源文件“glibconfig.h”(“gtk/gtk.h”的依赖项)
【发布时间】:2020-05-25 10:20:25
【问题描述】:

我已经在 Visual Studio Code 中配置了任务 json

{
    "tasks": [
        {
            "type": "shell",
            "label": "gcc build active file",
            "command": "/usr/lib64/ccache/gcc",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "`pkg-config", "--cflags", "--libs","gtk+-3.0`"
            ],
            "options": {
                "cwd": "/usr/lib64/ccache"
            },
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

而且我认为终端输出没问题,它构建没有问题:

> Executing task: /usr/lib64/ccache/gcc -g /home/giuliohome/dev/gnome/gtk-example/gtk_hello02.c -o /home/giuliohome/dev/gnome/gtk-example/gtk_hello02 `pkg-config --cflags --libs gtk+-3.0` <

出于一个奇怪的原因,我不太了解,Visual Studio Code 编辑器需要在 .vscode/c_cpp_properties.json 中进行不同的单独配置,并且它仍然在 #include &lt;gtk/gtk.h&gt; 下抱怨 squiggles

问题信息说明:

无法打开源文件“glibconfig.h”(依赖于“gtk/gtk.h”)

我已经尝试通过目视检查我的 /usr/inlcude 结构添加 3 个目录

但是(因为它包含很多文件和子文件夹)我对这种方式感到困惑(我应该继续搜索所有嵌套的包含依赖项?)无论如何我不知道要添加什么接下来...

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/linux",
                "/usr/include/gtk-3.0",
                "/usr/include/glib-2.0"
            ],
            "defines": [],
            "compilerPath": "/usr/lib64/ccache/gcc",
            "cStandard": "c11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

【问题讨论】:

    标签: c gcc visual-studio-code gtk


    【解决方案1】:

    通过将以下内容添加到includePath,我能够消除错误:

            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/glib-2.0",
                "/usr/lib/x86_64-linux-gnu/glib-2.0/include"
            ],
    

    【讨论】:

      【解决方案2】:

      两年后,这仍然是open issue of Studio Code

      显然它是不可管理的,无论如何,为了您的信息,这是我的 Fedora 31 Linux 工作站上的解决方案:

      {
          "configurations": [
              {
                  "name": "Linux",
                  "includePath": [
                      "${workspaceFolder}/**",
                      "/usr/include/linux",
                      "/usr/include/gtk-3.0",
                      "/usr/include/glib-2.0",
                      "/usr/lib64/glib-2.0/include",
                      "/usr/include/pango-1.0",
                      "/usr/include/harfbuzz",
                      "/usr/include/cairo",
                      "/usr/include/gdk-pixbuf-2.0",
                      "/usr/include/atk-1.0"
                  ],
                  "defines": [],
                  "compilerPath": "/usr/lib64/ccache/gcc",
                  "cStandard": "c11",
                  "cppStandard": "gnu++14",
                  "intelliSenseMode": "clang-x64"
              }
          ],
          "version": 4
      }
      

      【讨论】:

        猜你喜欢
        • 2021-12-22
        • 2021-12-17
        • 2021-01-19
        • 1970-01-01
        • 2021-06-09
        • 2010-11-05
        • 1970-01-01
        • 2019-01-01
        • 1970-01-01
        相关资源
        最近更新 更多