New functions.
[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 binary packages, see
6 http://www.iki.fi/tml/gimp/win32/ . "Native" means that we use the
7 Win32 API only, and not any POSIX emulation layer except that provided
8 by the Microsoft runtime C library. Additionally, a pthreads emulation
9 library is used.
10
11 To build GLib on Win32, you can use either the Microsoft compiler and
12 tools, or gcc. Both the compiler from MSVC 5.0 and from MSVC 6.0 have
13 been used successfully. With gcc I mean gcc-2.95 as distributed by
14 Mumit Khan, running under cygwin-b20.1. To successfully use gcc,
15 follow the instructions below. We want to use gcc -mno-cygwin,
16 i.e. produce executables (.exe and .dll files) that do *not* require
17 the cygwin runtime library. This is sometimes called "mingw32".
18
19 To test the GLib functions, go to the tests subdirectory and enter
20 `nmake -f makefile.msc check` or `make -f makefile.cygwin check`.
21
22 If you would want to use the cygwin tools to generate executables that
23 *do* use the cygwin runtime, the normal Unix configuration method
24 should work as if on Unix. But it won't produce DLLs. At least I
25 haven't succeeded in that.
26
27 With a little work, it might be possible to use the ./configure
28 mechanism also with a "mingw32" configuration.
29
30 The following preprocessor macros are defined in glibconfig.h and used
31 for conditional compilation related to Win32:
32
33 - WIN32 is defined when compiling for the Win32 platform, regardless
34   if using the X11 or Win32 windowing API (in the case of GLib, this
35   dimension isn't significant), regardless whether using a more or
36   less complete POSIX emulation runtime layer (like Cygwin) or not.
37
38 - NATIVE_WIN32 is defined when compiling for Win32, *and* without
39   any POSIX emulation, other that to the extent provided by the
40   bundled Microsoft C library (msvcrt.dll) and the pthreads-win32
41   library. For instance, pathnames are in the native Windows syntax.
42
43 The Win32 port uses the combination with both of those on. As these
44 are in glibconfig.h, they are available to all source files that use
45 GLib (or GTk+, which uses GLib).
46
47 Additionally, there are the compiler-specific macros:
48 - _MSC_VER is defined when using the Microsoft compiler
49 - __GNUC__ is defined when using GCC
50
51 Some of the usage of these macros used to be a bit mixed up, and had
52 to be straightened out when adding the gcc support. In particular, I
53 used to check for _MSC_VER in some places where I really wanted to
54 check for the Microsoft C library, and those checks has now been
55 changed to NATIVE_WIN32. NATIVE_WIN32 ought to be renamed to
56 USE_MSVCRT.
57
58 Pthreads library
59 ================
60
61 Before building you must get the pthreads library for Win32 from
62 http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32
63 snapshot from 1999-05-30 is the one that should be used. Edit the
64 location of the pthreads library and include files in makefile.msc or
65 makefile.cygwin. The pthreads distribution includes the precompiled dll
66 and import libraries both for MSVC and gcc.
67
68 The pthreads for Win32 package that the thread support uses supposedly
69 isn't quite ready yet, and thus threads stuff should not be relied
70 upon for anything serious.
71
72 Where are the makefiles?
73 ========================
74
75 If you are building from a CVS snapshot, you will not have any
76 makefile.msc or makefile.cygwin file. You should copy the
77 corresponding makefile.msc.in or makefile.cygwin.in file to that name,
78 and edit the line that sets GLIB_VER to the correct version number.
79
80 This is done automatically when an official distribution package is
81 built.
82
83 Building with MSVC
84 ==================
85
86 If using the Microsoft toolchain, build with `nmake -f
87 makefile.msc`. Install with `nmake -f makefile.msc install`. 
88
89 Building with gcc
90 =================
91
92 The gcc support was added quite recently, but seems to work. Debugging
93 with gdb works. I use the latest and greatest gcc and mingw32.
94 Somewhat earlier versions will also work, but you are on your own.
95
96 Read and understand these instruction carefully. If you don't
97 understand or can't follow the instructions, you probably shouldn't
98 want to build glib (or gtk or gimp) yourself anyway.
99
100 Fetch gcc-2.95 built for cygwin from
101 ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/cygwin/gcc-2.95/gcc-2.95-cygb20.tar.gz
102 Install it somewhere, for instance "C:\gcc-2.95" (/gcc-2.95 as seen
103 from cygwin). We call this directory $GCCDIR below. You will have
104 subdirectories "H-i586-cygwin32" and "include" under $GCCDIR.
105
106 Next, you need to modify the gcc setup to use the msvcrt runtime
107 instead of crtdll. Also, the mingw32 and win32 API headers and import
108 libraries need to be added. I have collected all the necessary
109 additions in the file
110 http://www.iki.fi/tml/gimp/win32/gcc-2.95-additions.zip . Install that
111 in $GCCDIR. If you really want to do everything by yourself, follow
112 the instructions in
113 http://www.iki.fi/tml/gimp/win32/gcc-environment-setup.html
114
115 Next, go back to the GLib directory and build using `make -f
116 makefile.cygwin`.  Building the dlls uses the script build-dll which
117 is somewhat of a hack. But I couldn't get things working in a cleaner
118 way.
119
120 --Tor Lillqvist <tml@iki.fi>