Reprinted please indicate the source and the author contact: http://blog.csdn.net/mimepp
Contact information: Yu Tao <yut616 at Sohu dot com>
Recently, I have made an experiment on GTK + compilation in windows. Here I will take a note.
1. The compilation environment includes mingw + msys. For details, refer to my blog:
Compile FFMPEG in Win32
Http://blog.csdn.net/mimepp/archive/2008/04/26/2332751.aspx
This section describes how to create a mingw + msys environment.
Let's assume that you have created mingw + msys in the above method, for example:
C:/msys/mingw
2. download the required package from the GTK Official Website:
Http://www.gtk.org/download-windows.html
You can only download the content of all-in-one bundle, which is a whole package.
The preceding example is gtk0000-bundle-2.12.9.zip:
Http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.12/gtk+-bundle-2.12.9.zip
3. Unpack the package to the root directory of C:/msys/mingw, that is, you will see the bin, include, lib and other directories.
Of course, my previous practice is to download all the compressed files on the page at one time using Xunlei, and decompress them one by one to the mingw directory.
4. Find a simple example of Hello. C:
For example, D:/software/Hello. C # include <GTK/GTK. h>
Static gboolean delete_event (gtkwidget * widget, gdkevent * event, gpointer data)
{
G_print ("delete event occurred ");
Return false;
}
Static void destroy (gtkwidget * widget, gpointer data)
{
Gtk_main_quit ();
}
Int main (INT argc, char * argv [])
{
Gtkwidget * window;
Gtkwidget * label;
Gtk_init (& argc, & argv );
Window = gtk_window_new (gtk_window_toplevel );
G_signal_connect (g_object (window), "delete_event", g_callback (delete_event), null );
G_signal_connect (g_object (window), "Destroy", g_callback (destroy), null );
Label = gtk_label_new ("Hello GTK ");
Gtk_container_add (gtk_container (window), label );
Gtk_container_set_border_width (gtk_container (window), 10 );
Gtk_widget_show (Label );
Gtk_widget_show (window );
Gtk_main ();
Return 0;
}
5. Compile hello. C.
Command Line for msys: $ CD/D/software
$ Pwd
/D/software
$ Gcc-G hello. C-O hello 'pkg-config -- cflags GTK +-2.0 ''PKG-config -- libs GTK +-2.0'
6. Execute
$./Hello.exe
7. Results