Objectives : create standalone GTK+3 executables under Windows.
Following this previous article, here is everything necessary to create static GTK+ 3.4.2 executables on Windows.
It may be useful to remind that what we want : instead of ending up with a tree full of DLLs and resource files, we will put everything in one single binary. This may be useful for demos, installers...
Windows-specific code in GTK+3 tree (and some dependencies) is really not intended to be compiled statically. That's why many modifications are required to obtain this :
There are no GTK+3 DLLs in this folder...
... though gtk3-demo.exe (static) runs !
To try it, download :
gtk3-demo_static-WIN32.zip (5.51 Mb)
It should work even if there are no GTK+3 DLLs on the system.
(PS : some demos crash due to missing resource files. But we can notice that the theme still adapts to the underlying OS, and even that internationalization works if we copy the "/share/locale" directory from a full installation in the same folder)
It you want to compile such executables yourself, download :
gtk342_static-WIN32_(TARNYKO).zip (14.6 Mb)
Requires a full MinGW installation.
Extract the archive in c:\ to obtain c:\gtk342_static, then compile your program using this kind of command :
gcc myprogram.c -o myprogram.exe -Ic:\gtk342_static\include\gtk-3.0 -Ic:\gtk342_static\include\glib-2.0 -Ic:\gtk342_static\lib\glib-2.0\include -Ic:\gtk342_static\include\gdk-pixbuf-2.0 -Ic:\gtk342_static\include\pango-1.0 -Ic:\gtk342_static\include\cairo -Ic:\gtk342_static\include\atk-1.0 -Lc:\gtk342_static\lib -lgtk-3 -lgdk-3 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lpango-1.0 -latk-1.0 -lcairo -lcairo-gobject -lpangocairo-1.0 -lintl -lgmodule-2.0 -lgio-2.0 -limm32 -luser32 -lgdi32 -luuid -lole32 -lpng -lgdiplus -lpangowin32-1.0 -lffi -lws2_32 -lwinmm -lglib-2.0 -lpixman-1 -lfreetype -lfontconfig -lpangoft2-1.0 -lmsimg32 -liconv -lshlwapi -lz -lgdi32 -ldnsapi -lusp10 -lfreetype -lexpat -lgcc -lkernel32 -lmsvcrt
(PS : do not change the flags order, it matters)
Here we go !