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