Blame README.win32

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

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

Packit 98cdb6
Building GTK+ on Win32
Packit 98cdb6
======================
Packit 98cdb6

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

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

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

Packit 98cdb6
1) GNU tools, ./configure && make install
Packit 98cdb6
-----------------------------------------
Packit 98cdb6

Packit 98cdb6
This requires you have mingw and MSYS.
Packit 98cdb6

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

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

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

Packit 98cdb6
MOD=gtk+
Packit 98cdb6
VER=2.16.5
Packit 98cdb6
REV=1
Packit 98cdb6
ARCH=win32
Packit 98cdb6

Packit 98cdb6
THIS=${MOD}_${VER}-${REV}_${ARCH}
Packit 98cdb6

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

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

Packit 98cdb6
usedev
Packit 98cdb6
usemsvs6
Packit 98cdb6

Packit 98cdb6
(
Packit 98cdb6

Packit 98cdb6
set -x
Packit 98cdb6

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

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

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

Packit 98cdb6
patch -p0 <<'EOF'
Packit 98cdb6
EOF
Packit 98cdb6

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

Packit 98cdb6
libtoolcacheize &&
Packit 98cdb6
rm gtk/gtk.def &&
Packit 98cdb6
(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 98cdb6

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

Packit 98cdb6
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 98cdb6
    mv $TARGET/etc/gtk-2.0/gdk-pixbuf.loaders.temp $TARGET/etc/gtk-2.0/gdk-pixbuf.loaders &&
Packit 98cdb6
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 98cdb6
    mv $TARGET/lib/gtk-2.0/2.10.0/immodules.temp $TARGET/lib/gtk-2.0/2.10.0/immodules.cache &&
Packit 98cdb6

Packit 98cdb6
./gtk-zip.sh &&
Packit 98cdb6

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

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

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

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

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

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

Packit 98cdb6

Packit 98cdb6
2) Microsoft's tools
Packit 98cdb6
--------------------
Packit 98cdb6

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

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

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

Packit 98cdb6
https://live.gnome.org/GTK%2B/Win32/MSVCCompilationOfGTKStack 
Packit 98cdb6

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

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

Packit 98cdb6
Using GTK+ on Win32
Packit 98cdb6
===================
Packit 98cdb6

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

Packit 98cdb6
Multi-threaded use of GTK+ on Win32
Packit 98cdb6
===================================
Packit 98cdb6

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

Packit 98cdb6
Wintab
Packit 98cdb6
======
Packit 98cdb6

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

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