Include also the gtk-doc/html documentation in the developer package.
[platform/upstream/glib.git] / README.win32
1 Tor Lillqvist <tml@iki.fi>
2 Hans Breuer <hans@breuer.org>
3
4 The general parts, and the stuff about gcc and autoconfiscated build
5 are by Tor Lillqvist. The stuff about MSVC build is by Hans Breuer.
6
7 General
8 =======
9
10 For prebuilt binaries (DLLs and EXEs) and developer packages (headers,
11 import libraries) of GLib, GTK+, GIMP etc for Windows, surf to
12 http://www.gimp.org/win32/ . They are for "native" Windows meaning
13 they use the Win32 API and Microsoft C runtime library only, no POSIX
14 (Unix) emulation layer (like Cygwin). 
15
16 To build GLib on Win32, you can use either gcc or the Microsoft
17 compiler and tools. Both the compiler from MSVC 5.0 and from MSVC 6.0
18 have been used successfully.
19
20 But note that to just *use* GLib on Windows, there is no need to build
21 it yourself. Prepackaged runtime and developer packages are available
22 from the webiste above. On Unix, it is quite normal that system admins
23 build and install libraries like GLib themselves. But on Windows
24 setting up a correct build environment can be quite a task, especially
25 if you are used to just type "./configure; make" on Unix, and expect
26 things to work as smoothly on Windows.
27
28 The following preprocessor macros can be used for conditional
29 compilation related to Win32 in GLib-using code:
30
31 - G_OS_WIN32 is defined when compiling for native Win32, without
32   any POSIX emulation, other than to the extent provided by the
33   bundled Microsoft C library (msvcrt.dll).
34
35 - G_WITH_CYGWIN is defined if compiling for the Cygwin
36   environment. Note that G_OS_WIN32 is *not* defined in that case, as
37   Cygwin is supposed to behave like Unix. G_OS_UNIX *is* defined when
38   compiling for Cygwin.
39
40 - G_PLATFORM_WIN32 is defined when either G_OS_WIN32 or G_WITH_CYGWIN
41   is defined.
42
43 These macros are defined in glibconfig.h, and are thus (indirectly)
44 available in all source files that include <glib.h> or GTK+ headers.
45
46 Additionally, there are the compiler-specific macros:
47 - __GNUC__ is defined when using gcc
48 - _MSC_VER is defined when using the Microsoft compiler
49
50 G_OS_WIN32 implies using the Microsoft C runtime MSVCRT.DLL. GLib is
51 not known to work with the older CRTDLL.DLL runtime, or the static
52 Microsoft C runtime libraries LIBC.LIB and LIBCMT.LIB. It apparently
53 does work with the debugging version of MSVCRT.DLL, MSVCRTD.DLL.
54
55 Building software that use GLib or GTK+
56 =======================================
57
58 Even building software that just *uses* GLib or GTK+ also require to
59 have the right compiler set up the right way, so if you intend to use
60 gcc, follow the relevant instructions below in that case, too.
61
62 Tor uses gcc with the -mms-bitfields flag (used to be called
63 -fnative-struct in gcc 2.x), which means that in order to use the
64 prebuilt DLLs (especially of GTK+), if you compile your code with gcc,
65 you *must* also use that flag. (This flag means that the struct layout
66 rules are identical to those used by MSVC. This is essential if the
67 same DLLs are to be usable both from gcc- and MSVC-compiled code. This
68 definitely is something one wants.)
69
70 Building GLib
71 =============
72
73 Again, first decide whether you really want to do this.
74
75 Before building GLib you must also have the libiconv library, either
76 from the same website mentioned above, or from it's homepage at
77 http://clisp.cons.org/~haible/packages-libiconv.html. Libiconv has
78 makefiles for building with MS Visual C only, but as it is one source
79 file only, building it "by hand" with gcc isn't hard.
80
81 You must also have the "intl" library from GNU tettext 0.10.40 (or
82 later). Get a prebuilt version from the website mentioned above.
83
84 Edit the correct paths to those libraries in build/win32/module.defs
85 as appropriate.
86
87 Where are the makefiles?
88 ========================
89
90 If you are building from a CVS snapshot, you will not have any
91 makefile.mingw or makefile.msc files. You should copy the
92 corresponding makefile.mingw.in or makefile.msc.in file to that name,
93 and replace any @...@ strings with the correct value.
94
95 This is done automatically when an official GLib source distribution
96 package is built, so if you get GLib from a source distribution
97 package, there should be makefile.mingw and makefile.msc files ready
98 to use (after some editing).
99
100 Building GLib with gcc
101 ======================
102
103 Tor uses gcc 3.2. Version 2.95.3 also works.
104
105 You can either use gcc running on Cygwin, or the "pure" mingw
106 gcc. Using the latter might work better, or at least did at some
107 point.
108
109 Fetch the latest version of gcc for mingw and the msvcrt runtime, from
110 www.mingw.org.
111
112 Set up your PATH so that the gcc from the bin directory that got
113 created above is the one that gets used. Even if you run the mingw
114 gcc, you still want to have Cygwin to run make in.
115
116 Then run make -f makefile.mingw. Install the resulting DLLs somewhere
117 in your PATH. You can either keep the headers and import libraries
118 where they are, or install them somewhere else. There are no rules in
119 the makefile.mingws for installing, it is up to you where to put them.
120
121 Autoconfiscated build
122 =====================
123
124 It is also possible to use the auto*, ./configure and libtool
125 mechanism when building with gcc. You should be running Cygwin, or
126 maybe cross-compiling from real Unix, for the configure script to
127 work, obviously. It is also possible to use MSYS.
128
129 When building from an official source distribution, to be able to
130 build DLLs without problems, it might well be necessary to have a
131 relatively new version of libtool installed. If so, replace the
132 libtool parts included with GLib sources with newer versions by
133 running libtoolize --force. After that you want to run aclocal-1.4 and
134 autoconf before running configure.
135
136 Tor invokes configure using:
137
138 CC='gcc -mcpu=pentium3' CPPFLAGS='-I/target/include' 
139   CFLAGS=-O3 LDFLAGS='-L/target/lib' ./configure --with-libiconv 
140   --disable-static --prefix=/target --host=i386-pc-mingw32 
141
142 (on a single line). The /target/include mentioned contains the header
143 files for libintl and libiconv, and the (import) libraries are in
144 /target/lib. This happens to be in the same tree where he configures
145 GLib to be installed, but doesn't have to be.
146
147 Please note that the ./configure mechanism should not blindly be used
148 to build a GLib to be distributed to other developers because it
149 produces a compiler-dependent glibconfig.h (and config.h, but that
150 shouldn't matter, as it isn't seen by GLib-using applications). For
151 instance, the typedef for gint64 is long long with gcc, but __int64
152 with MSVC.
153
154 Except for this and a few other minor issues, there really shouldn't
155 be any reason to distribute separate GLib headers and DLLs for gcc and
156 MSVC users, as the compilers generate code that uses the same C
157 runtime library, and is mutually binary compatible. Thus one either
158 has to manually edit glibconfig.h afterwards, or use the supplied
159 glibconfig.h.win32. This has been produced by running configure twice,
160 once using gcc and once using MSVC, and merging the resulting files
161 with diff -D.
162
163 The hand-written makefile.{mingw,msc} files, and the stuff in the
164 "build" subdirectory, produce DLLs and import libraries that match
165 what Makefile.am and libtool produces. For GLib, the DLL is called
166 libglib-2.0-0.dll, and the import libraries libglib-2.0.dll.a and
167 glib-2.0.lib. Note that the "2.0" is part of the "basename" of the
168 library, it is not something that libtool has tucked on. The -0 suffix
169 is the value of "LT_CURRENT - LT_AGE". The 0 is *not* simply the micro
170 version number of GLib, although, for GLib 2.2.0, it happens to be the
171 same. The LT_CURRENT - LT_AGE value will on purpose be kept as zero as
172 long as binary compatibility is maintained. For the gory details, see
173 configure.in and libtool documentation.
174
175 If you want to run the Cygwin-hosted gcc, and still want to produce
176 code that does not use Cygwin, but the msvcrt runtime, in theory it
177 should work to use the -no-cygwin flag, but Tor hasn't tested that
178 lately.
179
180 If you would want to use the Cygwin tools to generate a GLib that
181 *does* use the Cygwin runtime, the normal Unix configuration method
182 should work as if on Unix. Note that successfully producing shared
183 libraries (DLLs) for Cygwin most probably requires you to have a very
184 new libtool. (And a new libtool probably requires rather new autoconf
185 and automake.) Tor hasn't tested this in a while, either.
186
187 Building with MSVC
188 ==================
189
190 All the MSVC makefiles are for the command line build with nmake.  If
191 you want to use the VC-UI you can simply create wrapper .dsp makefiles
192 (read the VC docs how to do so).
193
194 Some modules may require Perl to auto-generate files. The goal (at
195 least Hans's) is to not require any more tools.
196
197 Build with:
198
199 nmake -f makefile.msc
200   or
201 nmake -f makefile.msc DEBUG=1
202
203 [
204  The former will create 'release' versions of the DLLs. If you
205  plan to distribute you DLLs please use this command. The latter 
206  will create DLLs with debug information _and_ link them with
207  msvcrtd.dll instead of msvcrt.dll. 
208  Beware: There are known problems with mixing DLLs in one 
209  application, which are build against different runtimes. 
210  Especially the index-to-file mapping used by 'unix-style' file
211  operation - _open() _pipe() etc. - breaks sometimes in strange 
212  ways (for example the Gimp plug-in communication).
213 ]
214
215 Required libraries (not build from cvs)
216 ==================
217   libintl (gnu-intl), libiconv
218   libtiff, libpng, zlib, libjpeg
219
220 are available pre-built from the website mentioned above.
221
222 Versioning
223 ==========
224 Instead of the Unix and auto* way of tracking versions and resolving
225 dependencies (configure; make; make install) involving autoconf,
226 automake, libtool and friends the MSVC build uses a different
227 approach.
228
229 The core of it's versioning is the file build/win32/module.defs.
230 It contains entries of the form MODULE_VER, e.g.:
231
232         GLIB_VER = 2.0
233         LIBICONV_VER = 1.3
234
235 and the placement of these modules defined as MODULE, e.g.:
236
237         GLIB = $(TOP)/glib
238         LIBICONV = $(TOP)/libiconv-$(LIBICONV_VER)
239
240 whereas TOP is defined as the relative path from the respective
241 module directory to your top build directory. Every makefile.msc
242 needs to define TOP before including the common make file part
243 make.msc, which than includes module.defs, like:
244
245 TOP = ../..
246 !INCLUDE $(TOP)/glib/build/win32/make.msc
247
248 (Taken from gtk+/gdk/makefile.msc)
249
250 With this provision it is possible to create almost placement
251 independent makefiles without requiring to 'install' the libraries and
252 headers into a common place (as it is done on Unix, and as Tor does
253 when producing his zipfiles with prebuilt GLib, GTK+ etc).
254
255 Special Files
256 =============
257         config.h.win32.in : @XXX_MAJOR_VERSION@ needs to be replaced by
258 the current version/build number. The resulting file is to be saved
259 as 'config.h.win32'. This should be automatically done if a package
260 gets build on the Unix platform.
261
262         makefile.msc.in : @XXX_MAJOR_VERSION@ to be replaced. Save as
263 makefile.msc.
264
265         <module>.def : every function which should be used from the outside of
266 a dll needs to be marked for 'export'. It is common that one needs to change 
267 these files after some api changes occured. If there are variables to be
268 exported another mechanism is needed, like :
269
270         #ifdef G_OS_WIN32
271         #  ifdef GDK_COMPILATION
272         #    define GDKVAR __declspec(dllexport)
273         #  else
274         #    define GDKVAR extern __declspec(dllimport)
275         #  endif
276         #else
277         #  define GDKVAR extern
278         #endif
279
280
281
282 Directory Structure
283 ===================
284 all modules should be build in a common directory tree otherwise you 
285 need to adapt the file 'module.defs'. They are listed here in increasing
286 dependencies order.
287
288 <common rootdir without spaces>
289   |
290   +- glib
291   |   |
292   |   +- build          : [this module lives in the cvs root dir]
293   |   |   +- win32
294   |   |       .\module.defs : defines (relative) locations of the headers
295   |   |                       and libs and version numbers to be include 
296   |   |                       in dll names
297   |   |       .\make.msc    : include by almost every 'makefile.msc'
298   |   |
299   |   | .\README.WIN32  : more information how to build
300   |   | .\glibconfig.h.win32.in : similar to config.h.win32.in
301   |   | .\makefile.msc  : master makefile, sub dir makefiles should work 
302   |   |
303   |   +- glib
304   |   +- gmodule
305   |   +- gthread        : does _not_ depend on pthread anymore
306   |   +- gobject
307   |
308   +- pango
309   |   +- pango          : 'native' build does not require extra libs and
310   |   |                 includes the minimal required text renderer
311   |   |                 (there is also a currently slightly broken FreeType2 
312   |   |                 based implementation for win32)
313   |   +- modules (not yet build)
314   |
315   +- atk
316   |   +- atk
317   |       .\makefile.msc : build here
318   |
319   +- gtk+
320   |   | .\config.h.win32 : for all the below
321   |   |
322   |   +- gdk-pixbuf
323   |   |   .\gdk_pixbuf.rc.in : version resource for the DLLs. Needs
324   |   |                 to be converted (filled with version info)
325   |   |                 as described above.
326   |   |
327   |   +- gdk
328   |   |   | .\makefile.msc : some auto-generation is needed to build in the
329   |   |   |             in the subdirectory 
330   |   |   +- win32
331   |   |
332   |   +- gtk
333
334   |
335   +- gimp
336   |   .\makefile.msc    : master makefile to build The Gimp. The makefiles
337   |                     from the sub dirs should work stand alone, but than
338   |                     the user needs to know the build order
339
340   |
341   +- dia                : additionally depends on libart_lgpl (in cvs)
342       |                 and libxml2 ( see http://www.xmlsoft.org/ )
343       +- lib
344       +- app
345       +- objects
346       +- plug-ins
347           +- python
348