Updates.
[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 DLLs, surf to http://www.gimp.org/win32/
6 "Native" means that we use the Win32 API only, and no POSIX (Unix)
7 emulation layer except that provided by the Microsoft runtime C
8 library. Actually, a pthreads emulation library is used.
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 not need to
15 build it, prebuilt DLLs are available from the webiste above.
16
17 With gcc I mean gcc-2.95 or gcc-2.95.2 as distributed by Mumit Khan,
18 either as a mingw version (preferred), or running under cygwin. To
19 successfully use gcc, follow the instructions below. We want to use
20 gcc -mno-cygwin, i.e. produce executables (.exe and .dll files) that
21 do *not* require the cygwin runtime library. This is called "mingw".
22 I also use the -fnative-struct flag, which means that in order to use
23 the prebuilt DLLs (especiall 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 - _WIN32 is defined by the compiler
48
49 The Win32 port uses the combination with both of those on. As
50 G_OS_WIN32 is defined in glibconfig.h, it is available to all source
51 files that use GLib (or GTk+, which uses GLib).
52
53 Additionally, there are the compiler-specific macros:
54 - _MSC_VER is defined when using the Microsoft compiler
55 - __GNUC__ is defined when using GCC
56
57 Some of the usage of these macros used to be a bit mixed up, and had
58 to be straightened out when adding the gcc support. In particular, I
59 used to check for _MSC_VER in some places where I really wanted to
60 check for the Microsoft C library, and those checks has now been
61 changed to G_OS_WIN32.
62
63 G_OS_WIN32 implies using the Microsoft C runtime MSVCRT.DLL. GLib or
64 software using it is not known to work with the older CRTDLL.DLL
65 runtime.
66
67 Building software that use GLib or GTk+
68 =======================================
69
70 Unfortunately, even building software that just *use* GLib or GTk+
71 also require to have the right compiler set up the right way, so if
72 you intend to use gcc, follow the relevant instructions below in that
73 case, too.
74
75 Pthreads library
76 ================
77
78 Before building you must get the pthreads library for Win32 from
79 http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32
80 snapshot from 1999-05-30 is the one that should be used. Edit the
81 location of the pthreads library and include files in makefile.msc or
82 makefile.mingw. The pthreads distribution includes the precompiled dll
83 and import libraries both for MSVC and gcc. Later versions might also
84 work.
85
86 The pthreads for Win32 package that the thread support uses supposedly
87 isn't quite ready yet, and thus threads stuff should not be relied
88 upon for anything serious.
89
90 Libiconv
91 ========
92
93 Before building GLib you must also have the libiconv library, either
94 from the same website mentioned above, or from it's homepage at
95 http://clisp.cons.org/~haible/packages-libiconv.html.
96
97 Where are the makefiles?
98 ========================
99
100 If you are building from a CVS snapshot, you will not have any
101 makefile.mingw or makefile.msc file. You should copy the corresponding
102 makefile.mingw.in or makefile.msc.in file to that name, and edit the
103 line that sets GLIB_VER to the correct version number.
104
105 This is done automatically when an official GLib source distribution
106 package is built.
107
108 Building with gcc
109 =================
110
111 I use the latest gcc, gcc-2.95.2. Version 2.95 will most probably also
112 work.
113
114 You can either use gcc running on cygwin, or the "pure" mingw
115 gcc. Using the latter is much easier. 
116
117 Just fetch the latest version of gcc for mingw and the msvcrt runtime,
118 currently from
119 ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1/
120 .
121
122 Download the three zip archives: the gcc-<version>-msvcrt,
123 mingw-msvcrt-<timestamp> and binutils-<timestamp>-msvcrt, and unpack
124 them in a suitable directory.
125
126 Set up your PATH so that the gcc from the bin directory that got
127 created above is the one that gets used. You can skip steps 1--5
128 below. Even if you run the mingw gcc, you still want to have cygwin to
129 run make in.
130
131 If you want to run a cygwin-based gcc, it gets a bit more
132 complicated. We still want gcc to produce code that does not use
133 cygwin, but the msvcrt runtime. The way to do this can be quite
134 complex, and the instructions are not included here. Contact me if you
135 want some possibly outdated, misleading and incomplete advice.
136
137 Building with MSVC
138 ==================
139
140 If using the Microsoft toolchain, build with `nmake -f
141 makefile.msc`. Install with `nmake -f makefile.msc install`. 
142
143 --Tor Lillqvist <tml@iki.fi>