Search code examples
gtkgtk3msys2

How to build a GTK3 application with msys2?


I had installed msys2 and mingw-gcc, gtk3 package.

pacman -S mingw-w64-i686-toolchain
pacman -S mingw-w64-i686-gtk3

Then I tried to build a test code.

// main.c
#include <stdio.h>
#include <gtk\gtk.h>

int main()
{
    printf("hello, msys2!");
    return 0;
}

but this test code wasn't build with error.

main.c:2:21: fatal error: gtk\gtk.h: No such file or directory

I checked gtk.h's location and fixed and rebuilded.

// #include <gtk\gtk.h> -> #include <gtk-3.0\gtk\gtk.h>
C:/msys32/mingw32/include/gtk-3.0/gtk/gtk.h:30:21: fatal error: gdk/gdk.h: No such file or directory

I guess there is my mistake i dont know.


Solution

  • go gtk3 tutorial site.

    and read gcc option.

    gcc `pkg-config --cflags gtk+-3.0` -o example-0 example-0.c `pkg-config --libs gtk+-3.0`