cannot open source file “glibconfig.h” (dependency of “gtk/gtk.h”) in Studio Code

做~自己de王妃 提交于 2020-06-01 05:11:12

问题


I've configured the task json in Visual Studio Code

{
    "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"
}

And I think the terminal output is ok,it builds without issues:

> 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` <

For a strange reason, that I don't deeply understand, the Visual Studio Code editor needs a different, separate configuration in .vscode/c_cpp_properties.json and it still complains with squiggles under the #include <gtk/gtk.h>

Message of the problem explains:

cannot open source file "glibconfig.h" (dependency of "gtk/gtk.h")

What I've tried to do was already adding 3 dirs by visual inspection of my /usr/inlcude structure

but (since it contains a lot of file and subfolders) I'm perplexed by this way to proceed (I'm I supposed to keep searching all those nested include dependencies?) and anyway I don't know what to add next...

{
    "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
}

回答1:


After two years, this is still an open issue of Studio Code.

It is obvious that it is not manageable, anyway, for your info, this is the solution on my Fedora 31 Linux workstation:

{
    "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
}


来源:https://stackoverflow.com/questions/62000384/cannot-open-source-file-glibconfig-h-dependency-of-gtk-gtk-h-in-studio-cod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!