glib.h: no such file or directory in gtkcss, despite following correct steps

32 Views Asked by At

for some reason, in the "problems" section in vscode terminal, it says "glib.h: no such file or directory", I followed steps to set up gtk4 in vscode in windows without cmake and with gcc, these are the steps that I followed:

I executed these commands in the msys terminal:

pacman -S mingw-w64-x86_64-gtk4
pacman -S mingw-w64-x86_64-toolchain base-devel

then I went to environment variables in system properties and in system variables I selected "Path", then I clicked on "edit", then "new" and after that, I added this directory: C:\msys64\mingw64\bin

then I added these directories to the include path in c_cpp_properties.json:

C:/msys64/mingw64/include/gtk-4.0
C:/msys64/mingw64/include/glib-2.0
C:/msys64/mingw64/include/**
C:/msys64/mingw64/lib/**

and this is my current c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/msys64/mingw64/include/gtk-4.0",
                "C:/msys64/mingw64/include/glib-2.0",
                "C:/msys64/mingw64/include/**",
                "C:/msys64/mingw64/lib/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:/msys64/mingw64/bin/gcc.exe",
            "cStandard": "c17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "windows-gcc-x64"
        }
    ],
    "version": 4
}

I executed this: pkg-config --cflags gtk4 in the windows terminal, and I got this:

-IC:/msys64/mingw64/bin/../include/gtk-4.0 -IC:/msys64/mingw64/bin/../include/pango-1.0 -IC:/msys64/mingw64/bin/../include/harfbuzz -IC:/msys64/mingw64/bin/../include/gdk-pixbuf-2.0 -IC:/msys64/mingw64/bin/../include/cairo -IC:/msys64/mingw64/bin/../include/glib-2.0 -IC:/msys64/mingw64/bin/../lib/glib-2.0/include -IC:/msys64/mingw64/bin/../include/freetype2 -IC:/msys64/mingw64/bin/../include/graphene-1.0 -IC:/msys64/mingw64/bin/../lib/graphene-1.0/include -mfpmath=sse -msse -msse2 -IC:/msys64/mingw64/bin/../include -IC:/msys64/mingw64/bin/../include/fribidi -IC:/msys64/mingw64/bin/../include/webp -DLIBDEFLATE_DLL -IC:/msys64/mingw64/bin/../include/libpng16 -IC:/msys64/mingw64/bin/../include/pixman-1

and I copied and pasted it in tasks.json and I arranged it like this:

"-IC:/msys64/mingw64/include/gtk-4.0",
"-IC:/msys64/mingw64/include/pango-1.0 ",
"-IC:/msys64/mingw64/include/harfbuzz ",
"-IC:/msys64/mingw64/include/gdk-pixbuf-2.0 ",
"-IC:/msys64/mingw64/include/cairo ",
"-IC:/msys64/mingw64/include/glib-2.0 ",
"-IC:/msys64/mingw64/lib/glib-2.0/include ",      
"-IC:/msys64/mingw64/include/freetype2 ",
"-IC:/msys64/mingw64/include/graphene-1.0 ",
"-IC:/msys64/mingw64/lib/graphene-1.0/include ",
"-mfpmath=sse",
"-msse",
"-msse2",
"-IC:/msys64/mingw64/include",
"-IC:/msys64/mingw64/include/fribidi ",
"-IC:/msys64/mingw64/include/webp ",
"-DLIBDEFLATE_DLL ",
"-IC:/msys64/mingw64/include/libpng16 ",
"-IC:/msys64/mingw64/include/pixman-1",

I deleted the "bin/.." in those directories.

then, I executed this in windows terminal: pkg-config --libs gtk4 and I got this: -LC:/msys64/mingw64/bin/../lib -lgtk-4 -lpangowin32-1.0 -lharfbuzz -lpangocairo-1.0 -lpango-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lglib-2.0 -lintl -lgobject-2.0

and I arranged it like this:

"-LC:/msys64/mingw64/bin/../lib",
"-lgtk-4 ",
"-lpangowin32-1.0 ",
"-lharfbuzz ",
"-lpangocairo-1.0 ",
"-lpango-1.0 ",
"-lgdk_pixbuf-2.0 ",
"-lcairo-gobject",
"-lcairo",
"-lgraphene-1.0",
"-lgio-2.0",
"-lglib-2.0",
"-lintl",
"-lgobject-2.0",

and this is how my tasks.json looks like currently:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:/msys64/mingw64/bin/gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "-IC:/msys64/mingw64/include/gtk-4.0",
                "-IC:/msys64/mingw64/include/pango-1.0 ",
                "-IC:/msys64/mingw64/include/harfbuzz ",
                "-IC:/msys64/mingw64/include/gdk-pixbuf-2.0 ",
                "-IC:/msys64/mingw64/include/cairo ",
                "-IC:/msys64/mingw64/include/glib-2.0 ",
                "-IC:/msys64/mingw64/lib/glib-2.0/include ",
                "-IC:/msys64/mingw64/include/freetype2 ",
                "-IC:/msys64/mingw64/include/graphene-1.0 ",
                "-IC:/msys64/mingw64/lib/graphene-1.0/include ",
                "-mfpmath=sse",
                "-msse",
                "-msse2",
                "-IC:/msys64/mingw64/include",
                "-IC:/msys64/mingw64/include/fribidi ",
                "-IC:/msys64/mingw64/include/webp ",
                "-DLIBDEFLATE_DLL ",
                "-IC:/msys64/mingw64/include/libpng16 ",
                "-IC:/msys64/mingw64/include/pixman-1",
                
                "${file}",

                "-LC:/msys64/mingw64/bin/../lib",
                "-lgtk-4 ",
                "-lpangowin32-1.0 ",
                "-lharfbuzz ",
                "-lpangocairo-1.0 ",
                "-lpango-1.0 ",
                "-lgdk_pixbuf-2.0 ",
                "-lcairo-gobject",
                "-lcairo",
                "-lgraphene-1.0",
                "-lgio-2.0",
                "-lglib-2.0",
                "-lintl",
                "-lgobject-2.0",

                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:/msys64/mingw64/bin/gcc.exe"
        }
    ],
    "version": "2.0.0"
}

then I went to my main.c program (the program where I should execute and display the gtk window with the hello world), and I clicked on "terminal" then, I clicked on "run tasks" and then, I selected this:

C/C++: gcc.exe build active file compiler: C:/msys64/mingw54/bin/gcc.exe

and I got this:

Starting build...
C:/msys64/mingw64/bin/gcc.exe -fdiagnostics-color=always -g -IC:/msys64/mingw64/include/gtk-4.0 "-IC:/msys64/mingw64/include/pango-1.0 " "-IC:/msys64/mingw64/include/harfbuzz " "-IC:/msys64/mingw64/include/gdk-pixbuf-2.0 " "-IC:/msys64/mingw64/include/cairo " "-IC:/msys64/mingw64/include/glib-2.0 " "-IC:/msys64/mingw64/lib/glib-2.0/include " "-IC:/msys64/mingw64/include/freetype2 " "-IC:/msys64/mingw64/include/graphene-1.0 " "-IC:/msys64/mingw64/lib/graphene-1.0/include " -mfpmath=sse -msse -msse2 -IC:/msys64/mingw64/include "-IC:/msys64/mingw64/include/fribidi " "-IC:/msys64/mingw64/include/webp " "-DLIBDEFLATE_DLL " "-IC:/msys64/mingw64/include/libpng16 " -IC:/msys64/mingw64/include/pixman-1 "C:\Users\user\Desktop\files\main.c" -LC:/msys64/mingw64/bin/../lib "-lgtk-4 " "-lpangowin32-1.0 " "-lharfbuzz " "-lpangocairo-1.0 " "-lpango-1.0 " "-lgdk_pixbuf-2.0 " -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lglib-2.0 -lintl -lgobject-2.0 -o "C:\Users\user\Desktop\files\main.exe"
In file included from C:/msys64/mingw64/include/gtk-4.0/gtk/gtk.h:29,
                 from C:\Users\user\Desktop\files\main.c:1:
C:/msys64/mingw64/include/gtk-4.0/gtk/css/gtkcss.h:29:10: fatal error: glib.h: No such file or directory
   29 | #include <glib.h>
      |          ^~~~~~~~
compilation terminated.

Build finished with error(s).

 *  The terminal process failed to launch (exit code: -1). 
 *  Terminal will be reused by tasks, press any key to close it. 

and then, I went to "problems" section and I saw in "C:\msys64\mingw64\include\gtk-4.0\gtk\css" the "glib.h: no such file or directory" error, this error occurs in the "gtkcss.h" header

0

There are 0 best solutions below