source: trunk/third/glib2/README.win32 @ 20721

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