]> Pileus Git - ~andy/gtk/blob - README.win32
stylecontext: Do invalidation on first resize container
[~andy/gtk] / README.win32
1 The Win32 backend in GTK+ is not as stable or correct as the X11 one.\r
2 \r
3 For prebuilt runtime and developer packages see\r
4 http://ftp.gnome.org/pub/gnome/binaries/win32/\r
5 \r
6 Building GTK+ on Win32\r
7 ======================\r
8 \r
9 First you obviously need developer packages for the compile-time\r
10 dependencies: GDK-Pixbuf, Pango, atk, glib, gettext-runtime, libiconv at least.\r
11 See http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies .\r
12 \r
13 For people compiling GTK+ with Visual C++ 2005 or later, it is\r
14 recommended that the same compiler is used for at least GDK-Pixbuf,\r
15 Pango, atk and glib so that crashes and errors caused by different CRTs\r
16 can be avoided.  The VS 2008 project files and/or VS Makefiles are\r
17 either already available or will be available in the next stable release.\r
18 Unfortunately compiling with Microsoft's compilers versions 2003 or earlier\r
19 is not supported as compiling the latest stable GLib (which *is* required for\r
20 building this GTK+ release) requires features from newer compilers\r
21 and/or Platform SDKs\r
22 \r
23 After installing the dependencies, there are two ways to build GTK+\r
24 for win32.\r
25 \r
26 1) GNU tools, ./configure && make install\r
27 -----------------------------------------\r
28 \r
29 This requires you have mingw and MSYS.\r
30 \r
31 Use the configure script, and the resulting Makefiles (which use\r
32 libtool and gcc to do the compilation). I use this myself, but it can\r
33 be hard to setup correctly.\r
34 \r
35 The full script I run to build GTK+ 2.16 unpacked from a source\r
36 distribution is as below. This is from bulding GTK+ 2.16.5. I don't\r
37 use any script like this to build the development branch, as I don't\r
38 distribute any binaries from development branches.\r
39 \r
40 # This is a shell script that calls functions and scripts from\r
41 # tml@iki.fi's personal work envĂ­ronment. It is not expected to be\r
42 # usable unmodified by others, and is included only for reference.\r
43 \r
44 MOD=gtk+\r
45 VER=2.16.5\r
46 REV=1\r
47 ARCH=win32\r
48 \r
49 THIS=${MOD}_${VER}-${REV}_${ARCH}\r
50 \r
51 RUNZIP=${MOD}_${VER}-${REV}_${ARCH}.zip\r
52 DEVZIP=${MOD}-dev_${VER}-${REV}_${ARCH}.zip\r
53 \r
54 HEX=`echo $THIS | md5sum | cut -d' ' -f1`\r
55 TARGET=c:/devel/target/$HEX\r
56 \r
57 usedev\r
58 usemsvs6\r
59 \r
60 (\r
61 \r
62 set -x\r
63 \r
64 DEPS=`latest --arch=${ARCH} glib atk cairo pango libpng zlib libtiff jpeg`\r
65 PROXY_LIBINTL=`latest --arch=${ARCH} proxy-libintl`\r
66 \r
67 PKG_CONFIG_PATH=\r
68 for D in $DEPS; do\r
69     PATH=/devel/dist/${ARCH}/$D/bin:$PATH\r
70     [ -d /devel/dist/${ARCH}/$D/lib/pkgconfig ] && PKG_CONFIG_PATH=/devel/dist/${ARCH}/$D/lib/pkgconfig:$PKG_CONFIG_PATH\r
71 done\r
72 \r
73 LIBPNG=`latest --arch=${ARCH} libpng`\r
74 ZLIB=`latest --arch=${ARCH} zlib`\r
75 LIBTIFF=`latest --arch=${ARCH} libtiff`\r
76 JPEG=`latest --arch=${ARCH} jpeg`\r
77 \r
78 patch -p0 <<'EOF'\r
79 EOF\r
80 \r
81 lt_cv_deplibs_check_method='pass_all' \\r
82 CC='gcc -mtune=pentium3 -mthreads' \\r
83 CPPFLAGS="-I/devel/dist/${ARCH}/${LIBPNG}/include \\r
84 -I/devel/dist/${ARCH}/${ZLIB}/include \\r
85 -I/devel/dist/${ARCH}/${LIBTIFF}/include \\r
86 -I/devel/dist/${ARCH}/${JPEG}/include \\r
87 -I/devel/dist/${ARCH}/${PROXY_LIBINTL}/include" \\r
88 LDFLAGS="-L/devel/dist/${ARCH}/${LIBPNG}/lib \\r
89 -L/devel/dist/${ARCH}/${ZLIB}/lib \\r
90 -L/devel/dist/${ARCH}/${LIBTIFF}/lib \\r
91 -L/devel/dist/${ARCH}/${JPEG}/lib \\r
92 -L/devel/dist/${ARCH}/${PROXY_LIBINTL}/lib -Wl,--exclude-libs=libintl.a \\r
93 -Wl,--enable-auto-image-base" \\r
94 LIBS=-lintl \\r
95 CFLAGS=-O2 \\r
96 ./configure \\r
97 --enable-win32-backend \\r
98 --disable-gdiplus \\r
99 --with-included-immodules \\r
100 --without-libjasper \\r
101 --enable-debug=yes \\r
102 --enable-explicit-deps=no \\r
103 --disable-gtk-doc \\r
104 --disable-static \\r
105 --prefix=$TARGET &&\r
106 \r
107 libtoolcacheize &&\r
108 rm gtk/gtk.def &&\r
109 (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)) &&\r
110 \r
111 PATH="/devel/target/$HEX/bin:$PATH" gdk-pixbuf-query-loaders >/devel/target/$HEX/etc/gtk-2.0/gdk-pixbuf.loaders &&\r
112 \r
113 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 &&\r
114     mv $TARGET/etc/gtk-2.0/gdk-pixbuf.loaders.temp $TARGET/etc/gtk-2.0/gdk-pixbuf.loaders &&\r
115 grep -v -E 'Automatically generated|Created by|ModulesPath =' <$TARGET/etc/gtk-2.0/gtk.immodules >$TARGET/etc/gtk-2.0/gtk.immodules.temp &&\r
116     mv $TARGET/etc/gtk-2.0/gtk.immodules.temp $TARGET/etc/gtk-2.0/gtk.immodules &&\r
117 \r
118 ./gtk-zip.sh &&\r
119 \r
120 mv /tmp/${MOD}-${VER}.zip /tmp/$RUNZIP &&\r
121 mv /tmp/${MOD}-dev-${VER}.zip /tmp/$DEVZIP\r
122 \r
123 ) 2>&1 | tee /devel/src/tml/packaging/$THIS.log\r
124 \r
125 (cd /devel && zip /tmp/$DEVZIP src/tml/packaging/$THIS.{sh,log}) &&\r
126 manifestify /tmp/$RUNZIP /tmp/$DEVZIP\r
127 \r
128 You should not just copy the above blindly. There are some things in\r
129 the script that are very specific to *my* build setup on *my* current\r
130 machine. For instance the "latest" command, the "usedev" and\r
131 "usemsvs6" shell functions, the /devel/dist folder. The above script\r
132 is really just meant for reference, to give an idea. You really need\r
133 to understand what things like PKG_CONFIG_PATH are and set them up\r
134 properly after installing the dependencies before building GTK+.\r
135 \r
136 As you see above, after running configure, one can just say "make\r
137 install", like on Unix. A post-build fix is needed, running\r
138 gdk-pixbuf-query-loaders once more to get a correct gdk-pixbuf.loaders\r
139 file.\r
140 \r
141 For a 64-bit build you need to remove the gtk/gtk.def file and let it\r
142 be regenerated by the makefilery. This is because the 64-bit GTK dll\r
143 has a slightly different list of exported function names. This is on\r
144 purpose and not a bug. The API is the same at the source level, and\r
145 the same #defines of some function names to actually have a _utf8\r
146 suffix is used (just to keep the header simpler). But the\r
147 corresponding non-suffixed function to maintain ABI stability are not\r
148 needed in the 64-bit case (because there are no older EXEs around that\r
149 would require such for ABI stability).\r
150 \r
151 \r
152 2) Microsoft's tools\r
153 --------------------\r
154 \r
155 Use the Microsoft compiler, cl and Make, nmake. Say nmake -f\r
156 makefile.msc in gdk and gtk. Be prepared to manually edit various\r
157 makefile.msc files, and the makefile snippets in build/win32.\r
158 \r
159 There are also VS 2008/2010 solution and project files to build GTK+, which\r
160 are maintained by Chun-wei Fan.  They should build GTK+ out of the box,\r
161 provided that the afore-mentioned dependencies are installed.  They will\r
162 build GDK with the Win32 backend, GTK+ itself (with GAIL/a11y built in),\r
163 the GAIL-Util library and the gtk-demo program.\r
164 \r
165 Please refer to the following GNOME Live! page for a more detailed ouline\r
166 on the process of building the GTK+ stack and its dependencies with Visual\r
167 C++:\r
168 \r
169 https://live.gnome.org/GTK%2B/Win32/MSVCCompilationOfGTKStack\r
170 \r
171 Alternative 1 also generates Microsoft import libraries (.lib), if you\r
172 have lib.exe available. It might also work for cross-compilation from\r
173 Unix.\r
174 \r
175 I (Tor) use method 1 myself. Hans Breuer has been taking care of the MSVC\r
176 makefiles. At times, we disagree a bit about various issues, and for\r
177 instance the makefile.msc files might not produce identically named\r
178 DLLs and import libraries as the "autoconfiscated" makefiles and\r
179 libtool do. If this bothers you, you will have to fix the makefiles.\r
180 \r
181 Using GTK+ on Win32\r
182 ===================\r
183 \r
184 To use GTK+ on Win32, you also need either one of the above mentioned\r
185 compilers. Other compilers might work, but don't count on it. Look for\r
186 prebuilt developer packages (DLLs, import libraries, headers) on the\r
187 above website.\r
188 \r
189 Multi-threaded use of GTK+ on Win32\r
190 ===================================\r
191 \r
192 Multi-threaded GTK+ programs might work on Windows in special simple\r
193 cases, but not in general. Sorry. If you have all GTK+ and GDK calls\r
194 in the same thread, it might work. Otherwise, probably not at\r
195 all. Possible ways to fix this are being investigated.\r
196 \r
197 Wintab\r
198 ======\r
199 \r
200 The tablet support uses the Wintab API. The Wintab development kit is\r
201 no longer required. The wintab.h header file is bundled with GTK+\r
202 sources. Unfortunately it seems that only Wacom tablets come with\r
203 support for the Wintab API nowadays.\r
204 \r
205 --Tor Lillqvist <tml@iki.fi>, <tml@novell.com>\r
206 --Updated by Fan, Chun-wei <fanc999@yahoo.com.tw>\r