How do I link gtk/gtk.h to my compiler in VSCode

45 Views Asked by At

I want to develop using gtk in VSCode. I am using C language. I am experiencing error as while compiling it giving an error of fatal error: gtk/gtk.h: No such file or directory

My c_cpp_properties.json file

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:/Users/ac701/College/C C++",
                "C:/msys64/mingw64/include/gtk-3.0",
                "C:/msys64/mingw64/include/gtk-4.0",
                "C:/msys64/mingw64/include/glib-2.0",
                "C:/msys64/mingw64/lib/glib-2.0/include",
                "C:/msys64/mingw64/include/pango-1.0",
                "C:/msys64/mingw64/include/harfbuzz",
                "C:/msys64/mingw64/include/cairo",
                "C:/msys64/mingw64/include/gdk-pixbuf-2.0",
                "C:/msys64/mingw64/include/atk-1.0"
            ],
            "defines": [],
            "compilerPath": "C:/msys64/mingw64/bin/gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

Note: all path exist and are correct.
Note2: while hovering to at include part I seen which directory is needed by gtk.h I added them as shown in json file and after all that it started showing gtk/gtk.h is not a directory.

I copied an helloworld code from internet.

#include <gtk/gtk.h>



// Function to create the GUI
static void activate(GtkApplication *app, gpointer user_data) {
    // Create a new window
    GtkWidget *window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "Hello World");
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);

    // Create a label
    GtkWidget *label = gtk_label_new("Hello, World!");

    // Add the label to the window
    gtk_container_add(GTK_CONTAINER(window), label);

    // Show all widgets
    gtk_widget_show_all(window);
}

int main(int argc, char **argv) {
    // Initialize GTK
    GtkApplication *app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
    g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
    int status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);
    return status;
}

P.S. I am new to programming so I maybe getting something wrong. I have tried the solution of similar problem from Stackoverflow but it does not seem to work.

I tried similar solution from stack and also tried cmake thing but i just cant seem to make development environment to work.

I want to compile but it showing an error gtk/gtk.h

0

There are 0 best solutions below