Blame README.win32

Packit Service fb6fa5
The Win32 backend in GTK+ is not as stable or correct as the X11 one.
Packit Service fb6fa5

Packit Service fb6fa5
For prebuilt runtime and developer packages see
Packit Service fb6fa5
http://ftp.gnome.org/pub/gnome/binaries/win32/
Packit Service fb6fa5

Packit Service fb6fa5
Building GTK+ on Win32
Packit Service fb6fa5
======================
Packit Service fb6fa5

Packit Service fb6fa5
First you obviously need developer packages for the compile-time
Packit Service fb6fa5
dependencies: GDK-Pixbuf, Pango, atk, glib, gettext-runtime, libiconv
Packit Service fb6fa5
at least.  See
Packit Service fb6fa5
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies.
Packit Service fb6fa5

Packit Service fb6fa5
For people compiling GTK+ on Visual C++ 2005 or later, it is recommended
Packit Service fb6fa5
that you build GDK-Pixbuf, Pango, atk, glib with the same compiler to avoid
Packit Service fb6fa5
crashes and errors caused by the usage of different CRTS.  VS 2008
Packit Service fb6fa5
project files and/or VS Makefiles are either already available in these
Packit Service fb6fa5
packages or will be available in the next stable release.  Unfortunately
Packit Service fb6fa5
compiling with Microsoft's compilers (version 2003 or earlier) is not
Packit Service fb6fa5
supported as compiling GLib requires features from the newer compilers
Packit Service fb6fa5
and/or the newer Platform SDKs at this time of writing.
Packit Service fb6fa5

Packit Service fb6fa5
After installing the dependencies, there are two ways to build GTK+
Packit Service fb6fa5
for win32.
Packit Service fb6fa5

Packit Service fb6fa5
1) GNU tools, ./configure && make install
Packit Service fb6fa5
-----------------------------------------
Packit Service fb6fa5

Packit Service fb6fa5
This requires you have mingw and MSYS.
Packit Service fb6fa5

Packit Service fb6fa5
Use the configure script, and the resulting Makefiles (which use
Packit Service fb6fa5
libtool and gcc to do the compilation). I use this myself, but it can
Packit Service fb6fa5
be hard to setup correctly.
Packit Service fb6fa5

Packit Service fb6fa5
The full script I run to build GTK+ 2.16 unpacked from a source
Packit Service fb6fa5
distribution is as below. This is from bulding GTK+ 2.16.5. I don't
Packit Service fb6fa5
use any script like this to build the development branch, as I don't
Packit Service fb6fa5
distribute any binaries from development branches.
Packit Service fb6fa5

Packit Service fb6fa5
# This is a shell script that calls functions and scripts from
Packit Service fb6fa5
# tml@iki.fi's personal work envĂ­ronment. It is not expected to be
Packit Service fb6fa5
# usable unmodified by others, and is included only for reference.
Packit Service fb6fa5

Packit Service fb6fa5
MOD=gtk+
Packit Service fb6fa5
VER=2.16.5
Packit Service fb6fa5
REV=1
Packit Service fb6fa5
ARCH=win32
Packit Service fb6fa5

Packit Service fb6fa5
THIS=${MOD}_${VER}-${REV}_${ARCH}
Packit Service fb6fa5

Packit Service fb6fa5
RUNZIP=${MOD}_${VER}-${REV}_${ARCH}.zip
Packit Service fb6fa5
DEVZIP=${MOD}-dev_${VER}-${REV}_${ARCH}.zip
Packit Service fb6fa5

Packit Service fb6fa5
HEX=`echo $THIS | md5sum | cut -d' ' -f1`
Packit Service fb6fa5
TARGET=c:/devel/target/$HEX
Packit Service fb6fa5

Packit Service fb6fa5
usedev
Packit Service fb6fa5
usemsvs6
Packit Service fb6fa5

Packit Service fb6fa5
(
Packit Service fb6fa5

Packit Service fb6fa5
set -x
Packit Service fb6fa5

Packit Service fb6fa5
DEPS=`latest --arch=${ARCH} glib atk cairo pango libpng zlib libtiff jpeg`
Packit Service fb6fa5
PROXY_LIBINTL=`latest --arch=${ARCH} proxy-libintl`
Packit Service fb6fa5

Packit Service fb6fa5
PKG_CONFIG_PATH=
Packit Service fb6fa5
for D in $DEPS; do
Packit Service fb6fa5
    PATH=/devel/dist/${ARCH}/$D/bin:$PATH
Packit Service fb6fa5
    [ -d /devel/dist/${ARCH}/$D/lib/pkgconfig ] && PKG_CONFIG_PATH=/devel/dist/${ARCH}/$D/lib/pkgconfig:$PKG_CONFIG_PATH
Packit Service fb6fa5
done
Packit Service fb6fa5

Packit Service fb6fa5
LIBPNG=`latest --arch=${ARCH} libpng`
Packit Service fb6fa5
ZLIB=`latest --arch=${ARCH} zlib`
Packit Service fb6fa5
LIBTIFF=`latest --arch=${ARCH} libtiff`
Packit Service fb6fa5
JPEG=`latest --arch=${ARCH} jpeg`
Packit Service fb6fa5

Packit Service fb6fa5
patch -p0 <<'EOF'
Packit Service fb6fa5
EOF
Packit Service fb6fa5

Packit Service fb6fa5
lt_cv_deplibs_check_method='pass_all' \
Packit Service fb6fa5
CC='gcc -mtune=pentium3 -mthreads' \
Packit Service fb6fa5
CPPFLAGS="-I/devel/dist/${ARCH}/${LIBPNG}/include \
Packit Service fb6fa5
-I/devel/dist/${ARCH}/${ZLIB}/include \
Packit Service fb6fa5
-I/devel/dist/${ARCH}/${LIBTIFF}/include \
Packit Service fb6fa5
-I/devel/dist/${ARCH}/${JPEG}/include \
Packit Service fb6fa5
-I/devel/dist/${ARCH}/${PROXY_LIBINTL}/include" \
Packit Service fb6fa5
LDFLAGS="-L/devel/dist/${ARCH}/${LIBPNG}/lib \
Packit Service fb6fa5
-L/devel/dist/${ARCH}/${ZLIB}/lib \
Packit Service fb6fa5
-L/devel/dist/${ARCH}/${LIBTIFF}/lib \
Packit Service fb6fa5
-L/devel/dist/${ARCH}/${JPEG}/lib \
Packit Service fb6fa5
-L/devel/dist/${ARCH}/${PROXY_LIBINTL}/lib -Wl,--exclude-libs=libintl.a \
Packit Service fb6fa5
-Wl,--enable-auto-image-base" \
Packit Service fb6fa5
LIBS=-lintl \
Packit Service fb6fa5
CFLAGS=-O2 \
Packit Service fb6fa5
./configure \
Packit Service fb6fa5
--with-gdktarget=win32 \
Packit Service fb6fa5
--disable-gdiplus \
Packit Service fb6fa5
--with-included-immodules \
Packit Service fb6fa5
--without-libjasper \
Packit Service fb6fa5
--enable-debug=yes \
Packit Service fb6fa5
--enable-explicit-deps=no \
Packit Service fb6fa5
--disable-gtk-doc \
Packit Service fb6fa5
--disable-static \
Packit Service fb6fa5
--prefix=$TARGET &&
Packit Service fb6fa5

Packit Service fb6fa5
libtoolcacheize &&
Packit Service fb6fa5
rm gtk/gtk.def &&
Packit Service fb6fa5
(PATH="$PWD/gdk-pixbuf/.libs:/devel/target/$HEX/bin:$PATH" make -j3 install || (rm .libtool-cache* && PATH="/devel/target/$HEX/bin:$PATH" make -j3 install)) &&
Packit Service fb6fa5

Packit Service fb6fa5
PATH="/devel/target/$HEX/bin:$PATH" gdk-pixbuf-query-loaders >/devel/target/$HEX/etc/gtk-2.0/gdk-pixbuf.loaders &&
Packit Service fb6fa5

Packit Service fb6fa5
grep -v -E 'Automatically generated|Created by|LoaderDir =' <$TARGET/etc/gtk-2.0/gdk-pixbuf.loaders >$TARGET/etc/gtk-2.0/gdk-pixbuf.loaders.temp &&
Packit Service fb6fa5
    mv $TARGET/etc/gtk-2.0/gdk-pixbuf.loaders.temp $TARGET/etc/gtk-2.0/gdk-pixbuf.loaders &&
Packit Service fb6fa5
grep -v -E 'Automatically generated|Created by|ModulesPath =' <$TARGET/lib/gtk-2.0/2.10.0/immodules.cache >$TARGET/lib/gtk-2.0/2.10.0/immodules.temp &&
Packit Service fb6fa5
    mv $TARGET/lib/gtk-2.0/2.10.0/immodules.temp $TARGET/lib/gtk-2.0/2.10.0/immodules.cache &&
Packit Service fb6fa5

Packit Service fb6fa5
./gtk-zip.sh &&
Packit Service fb6fa5

Packit Service fb6fa5
mv /tmp/${MOD}-${VER}.zip /tmp/$RUNZIP &&
Packit Service fb6fa5
mv /tmp/${MOD}-dev-${VER}.zip /tmp/$DEVZIP
Packit Service fb6fa5

Packit Service fb6fa5
) 2>&1 | tee /devel/src/tml/packaging/$THIS.log
Packit Service fb6fa5

Packit Service fb6fa5
(cd /devel && zip /tmp/$DEVZIP src/tml/packaging/$THIS.{sh,log}) &&
Packit Service fb6fa5
manifestify /tmp/$RUNZIP /tmp/$DEVZIP
Packit Service fb6fa5

Packit Service fb6fa5
You should not just copy the above blindly. There are some things in
Packit Service fb6fa5
the script that are very specific to *my* build setup on *my* current
Packit Service fb6fa5
machine. For instance the "latest" command, the "usedev" and
Packit Service fb6fa5
"usemsvs6" shell functions, the /devel/dist folder. The above script
Packit Service fb6fa5
is really just meant for reference, to give an idea. You really need
Packit Service fb6fa5
to understand what things like PKG_CONFIG_PATH are and set them up
Packit Service fb6fa5
properly after installing the dependencies before building GTK+.
Packit Service fb6fa5

Packit Service fb6fa5
As you see above, after running configure, one can just say "make
Packit Service fb6fa5
install", like on Unix. A post-build fix is needed, running
Packit Service fb6fa5
gdk-pixbuf-query-loaders once more to get a correct gdk-pixbuf.loaders
Packit Service fb6fa5
file.
Packit Service fb6fa5

Packit Service fb6fa5
For a 64-bit build you need to remove the gtk/gtk.def file and let it
Packit Service fb6fa5
be regenerated by the makefilery. This is because the 64-bit GTK dll
Packit Service fb6fa5
has a slightly different list of exported function names. This is on
Packit Service fb6fa5
purpose and not a bug. The API is the same at the source level, and
Packit Service fb6fa5
the same #defines of some function names to actually have a _utf8
Packit Service fb6fa5
suffix is used (just to keep the header simpler). But the
Packit Service fb6fa5
corresponding non-suffixed function to maintain ABI stability are not
Packit Service fb6fa5
needed in the 64-bit case (because there are no older EXEs around that
Packit Service fb6fa5
would require such for ABI stability).
Packit Service fb6fa5

Packit Service fb6fa5

Packit Service fb6fa5
2) Microsoft's tools
Packit Service fb6fa5
--------------------
Packit Service fb6fa5

Packit Service fb6fa5
Use the Microsoft compiler, cl and Make, nmake. Say nmake -f
Packit Service fb6fa5
makefile.msc in gdk and gtk. Be prepared to manually edit various
Packit Service fb6fa5
makefile.msc files, and the makefile snippets in build/win32.
Packit Service fb6fa5

Packit Service fb6fa5
There are also VS 2008/2010 solution and project files to build GTK+, which
Packit Service fb6fa5
are maintained by Chun-wei Fan. They should build GTK+ out of the box,
Packit Service fb6fa5
provided that the afore-mentioned dependencies are installed. They will
Packit Service fb6fa5
build GDK with the Win32 backend, GTK+ itself and the gtk-demo program.
Packit Service fb6fa5
(The GAIL and GAIL-util sources are not built by this method yet)
Packit Service fb6fa5

Packit Service fb6fa5
Please refer to the following GNOME Live! page for a more detailed ouline
Packit Service fb6fa5
on the process of building the GTK+ stack and its dependencies with Visual
Packit Service fb6fa5
C++:
Packit Service fb6fa5

Packit Service fb6fa5
https://live.gnome.org/GTK%2B/Win32/MSVCCompilationOfGTKStack 
Packit Service fb6fa5

Packit Service fb6fa5
Alternative 1 also generates Microsoft import libraries (.lib), if you
Packit Service fb6fa5
have lib.exe available. It might also work for cross-compilation from
Packit Service fb6fa5
Unix.
Packit Service fb6fa5

Packit Service fb6fa5
I (Tor) use method 1 myself. Hans Breuer has been taking care of the MSVC
Packit Service fb6fa5
makefiles. At times, we disagree a bit about various issues, and for
Packit Service fb6fa5
instance the makefile.msc files might not produce identically named
Packit Service fb6fa5
DLLs and import libraries as the "autoconfiscated" makefiles and
Packit Service fb6fa5
libtool do. If this bothers you, you will have to fix the makefiles.
Packit Service fb6fa5

Packit Service fb6fa5
Using GTK+ on Win32
Packit Service fb6fa5
===================
Packit Service fb6fa5

Packit Service fb6fa5
To use GTK+ on Win32, you also need either one of the above mentioned
Packit Service fb6fa5
compilers. Other compilers might work, but don't count on it. Look for
Packit Service fb6fa5
prebuilt developer packages (DLLs, import libraries, headers) on the
Packit Service fb6fa5
above website.
Packit Service fb6fa5

Packit Service fb6fa5
Multi-threaded use of GTK+ on Win32
Packit Service fb6fa5
===================================
Packit Service fb6fa5

Packit Service fb6fa5
Multi-threaded GTK+ programs might work on Windows in special simple
Packit Service fb6fa5
cases, but not in general. Sorry. If you have all GTK+ and GDK calls
Packit Service fb6fa5
in the same thread, it might work. Otherwise, probably not at
Packit Service fb6fa5
all. Possible ways to fix this are being investigated.
Packit Service fb6fa5

Packit Service fb6fa5
Wintab
Packit Service fb6fa5
======
Packit Service fb6fa5

Packit Service fb6fa5
The tablet support uses the Wintab API. The Wintab development kit is
Packit Service fb6fa5
no longer required. The wintab.h header file is bundled with GTK+
Packit Service fb6fa5
sources. Unfortunately it seems that only Wacom tablets come with
Packit Service fb6fa5
support for the Wintab API nowadays.
Packit Service fb6fa5

Packit Service fb6fa5
--Tor Lillqvist <tml@iki.fi>, <tml@novell.com>
Packit Service fb6fa5
--Updated by Fan, Chun-wei <fanc999@yahoo.com.tw>