Reputation:
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
}
Upvotes: 5
Views: 10696
Reputation: 98
I had the same issue. I simply removed the sub-directory and added the parent directory. The issue is now gone. Adding this as it'd be helpful to others.
"includePath": [
"${workspaceFolder}/**",
"/usr/include/**",
"/usr/lib/x86_64-linux-gnu/**"
],
Upvotes: 0
Reputation: 39297
I was able to get the error to go away by adding the following to the includePath
:
"includePath": [
"${workspaceFolder}/**",
"/usr/include/glib-2.0",
"/usr/lib/x86_64-linux-gnu/glib-2.0/include"
],
Upvotes: 14
Reputation:
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
}
Upvotes: 2