In
This article explains how to create and compile GTK under the Windows operating system. GTK uses glib, Cairo, pango, ATK, GTK +, and gettext-
Runtime, LibPNG, libjpeg, LibTIFF, and zlib. Therefore, you must also obtain these kits, which can be obtained from Windows download on the GTK official website, the simplest way is to get all-in-one bundle.
The following describes the steps for security protection:
- Renew minggw in http://www.mingw.org/
Obtained from GTK Official WebsiteAll-in-One bundle
- Select "security base Tools", "g ++", and "make ".
- Deploy all-in-one bundle
- Add the bin path of mingw to the path of Environment Change and the bin path of GTK after the environment change.
Labels:
$ PKG-config -- cflags -- libs GTK +-2.0> inc.txt |
The following commands can be used to obtain lib saved to lib.txt:
$ PKG-config -- Libs -- libs GTK +-2.0> lib.txt |
After a convenient start, you can write a complete set of makefilefiles, and specify the content of inc.txt‑lib.txt to cflags and libs:
CC = gcc
CFLAGS = -mms-bitfields -IC:/Winware/Gtk/include/gtk-2.0
-IC:/Winware/Gtk/lib/gtk-2.0/include -IC:/Winware/Gtk/include/atk-1.0
-IC:/Winware/Gtk/include/cairo -IC:/Winware/Gtk/include/pango-1.0
-IC:/Winware/Gtk/include/glib-2.0 -IC:/Winware/Gtk/lib/glib-2.0/include
-IC:/Winware/Gtk/include/libpng12
LIBS = -LC:/Winware/Gtk/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0
-lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lpango-1.0 -lcairo
-lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl
main:
$(CC) foo.c -o foo.exe $(CFLAGS) $(LIBS)
Then you can create a simple GTK program:
# Include <GTK/GTK. h>
Int main (INT argc, char * argv []) {
Gtkwidget * window;
Gtk_init (& argc, & argv );
Window = gtk_window_new (gtk_window_toplevel );
Gtk_window_set_title (gtk_window (window), "haha! GTK +! ");
Gtk_widget_show (window );
Gtk_main ();
Return 0;
}
In order to display Chinese characters, your case must be saved as a UTF-8 (without bom at the beginning of the statement), and then begin with the make command:
$ Make GCC Foo. C-o foo.exe-MMS-bitfields-ic:/winware/GTK/include/gtk-2.0-ic:/winwar E/GTK/lib/gtk-2.0/include-ic:/winware/GTK/include/atk-1.0-ic:/winware/GTK/incl Ude/Cairo-ic:/winware/GTK/include/pango-1.0-ic:/winware/GTK/include/glib-2.0- IC:/winware/GTK/lib/glib-2.0/include-ic:/winware/GTK/include/libpng12-LC:/winw Are/GTK/lib-lgtk-win32-2.0-lgdk-win32-2.0-latk-1.0-lgdk_pixbuf-2.0-lpangowi N32-1.0-lgdi32-lpangocairo-1.0-lpango-1.0-lcairo-lgobject-2.0-lgmodule-2.0 -Lglib-2.0-lintl
|
Run the following statement to create foo.exe: