Update.
[platform/upstream/glib.git] / README.win32
1 General
2 =======
3
4 For more information about the port or GLib, GTk+ and the GIMP to
5 native Windows, and pre-built binaries (DLLs), surf to
6 http://www.gimp.org/win32/ . "Native" means that we use the Win32 API
7 only, and no POSIX (Unix) emulation layer except that provided by the
8 Microsoft runtime C library, and a pthreads emulation library.
9
10 To build GLib on Win32, you can use either gcc or the Microsoft
11 compiler and tools. Both the compiler from MSVC 5.0 and from MSVC 6.0
12 have been used successfully.
13
14 But note that to just *use* GLib on Windows, there is no need to build
15 it, prebuilt DLLs are available from the webiste above.
16
17 With gcc I mean gcc-2.95.2 as distributed by Mumit Khan, either as a
18 mingw version (preferred), or running under cygwin. To successfully
19 use gcc, follow the instructions below. We want to use gcc
20 -mno-cygwin, i.e. produce executables (.exe and .dll files) that do
21 *not* require the cygwin runtime library. This is called "mingw".  I
22 also use the -fnative-struct flag, which means that in order to use
23 the prebuilt DLLs (especially of GTK+), you *must* also use that flag.
24 (This flag means that the struct layout is identical to that used by
25 MSVC.)
26
27 To test the GLib functions, go to the tests subdirectory and enter
28 `nmake -f makefile.msc check` or `make -f makefile.mingw check`.
29
30 If you would want to use the cygwin tools to generate executables that
31 *do* use the cygwin runtime, the normal Unix configuration method
32 should work as if on Unix. But it won't produce DLLs. At least I
33 haven't succeeded in that. Also, I have no idea what changes are
34 necessary to the code for it to run successfully on cygwin.
35
36 With some work, it might be possible to use the ./configure mechanism
37 also with a "mingw32" configuration.
38
39 The following preprocessor macros are used for conditional compilation
40 related to Win32:
41
42 - G_OS_WIN32 is defined when compiling for Win32, *and* without
43   any POSIX emulation, other that to the extent provided by the
44   bundled Microsoft C library (msvcrt.dll) and the pthreads-win32
45   library. For instance, pathnames are in the native Windows syntax.
46
47 - G_WITH_CYGWIN is defined if compiling for the Cygwin
48   environment. Note that G_OS_WIN32 is *not* defined in that case, as
49   Cygwin is supposed to behave like Unix. Building for Cygwin is not
50   supported. Some people have presumably done it, but no changes have
51   been submitted back.
52
53 The Win32 port of GLib and related software uses only G_OS_WIN32. As
54 G_OS_WIN32 is defined in glibconfig.h, it is available to all source
55 files that use GLib (or GTk+, which uses GLib).
56
57 Additionally, there are the compiler-specific macros:
58 - __GNUC__ is defined when using GCC
59 - _MSC_VER is defined when using the Microsoft compiler
60
61 G_OS_WIN32 implies using the Microsoft C runtime MSVCRT.DLL. GLib or
62 software using it is not known to work with the older CRTDLL.DLL
63 runtime.
64
65 Building software that use GLib or GTk+
66 =======================================
67
68 Even building software that just *use* GLib or GTk+ also require to
69 have the right compiler set up the right way, so if you intend to use
70 gcc, follow the relevant instructions below in that case, too.
71
72 Pthreads library
73 ================
74
75 Before building you must get the pthreads library for Win32 from
76 http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32
77 snapshot from 1999-05-30 is the one that should be used. Edit the
78 location of the pthreads library and include files in makefile.msc or
79 makefile.mingw. The pthreads distribution includes the precompiled dll
80 and import libraries both for MSVC and gcc. Later versions might also
81 work.
82
83 The pthreads for Win32 package that the thread support uses supposedly
84 isn't quite ready yet, and thus threads stuff should not be relied
85 upon for anything serious.
86
87 Libiconv
88 ========
89
90 Before building GLib you must also have the libiconv library, either
91 from the same website mentioned above, or from it's homepage at
92 http://clisp.cons.org/~haible/packages-libiconv.html.
93
94 Where are the makefiles?
95 ========================
96
97 If you are building from a CVS snapshot, you will not have any
98 makefile.mingw or makefile.msc file. You should copy the corresponding
99 makefile.mingw.in or makefile.msc.in file to that name, and edit the
100 line that sets GLIB_VER to the correct version number.
101
102 This is done automatically when an official GLib source distribution
103 package is built.
104
105 Building GLib with gcc
106 ======================
107
108 I use the latest gcc, gcc-2.95.2. Version 2.95 will most probably also
109 work.
110
111 You can either use gcc running on cygwin, or the "pure" mingw
112 gcc. Using the latter is much easier. 
113
114 Just fetch the latest version of gcc for mingw and the msvcrt runtime,
115 currently from
116 ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1/
117 .
118
119 Download the three zip archives: the gcc-<version>-msvcrt,
120 mingw-msvcrt-<timestamp> and binutils-<timestamp>-msvcrt, and unpack
121 them in a suitable directory.
122
123 Set up your PATH so that the gcc from the bin directory that got
124 created above is the one that gets used. You can skip steps 1--5
125 below. Even if you run the mingw gcc, you still want to have cygwin to
126 run make in.
127
128 If you want to run a cygwin-based gcc, it gets a bit more
129 complicated. We still want gcc to produce code that does not use
130 cygwin, but the msvcrt runtime. The way to do this can be quite
131 complex, and the instructions are not included here. Contact me if you
132 want some possibly outdated, misleading and incomplete advice.
133
134 Building with MSVC
135 ==================
136
137 If using the Microsoft toolchain, build with `nmake -f
138 makefile.msc`. Install with `nmake -f makefile.msc install`. 
139
140 --Tor Lillqvist <tml@iki.fi>