3bad679f5abe8c0207cb191298274b6d2868be98
[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 operating system emulation layer
8 except that provided by the Microsoft runtime C library. Actually,
9 a pthreads emulation library is used.
10
11 To build GLib on Win32, you can use either gcc or the Microsoft
12 compiler and tools. Both the compiler from MSVC 5.0 and from MSVC 6.0
13 have been used successfully. However, the makefiles for MSVC are not
14 up-to-date, sorry. If you fix the makefile.msc files, and manage to
15 build with MSVC, please send the updates makefile.msc files to the
16 gimpwin-dev list.
17
18 With gcc I mean gcc-2.95 or gcc-2.95.2 as distributed by Mumit Khan,
19 either as a mingw version (preferred), or running under cygwin. To
20 successfully use gcc, follow the instructions below. We want to use
21 gcc -mno-cygwin, i.e. produce executables (.exe and .dll files) that
22 do *not* require the cygwin runtime library. This is called "mingw".
23
24 To test the GLib functions, go to the tests subdirectory and enter
25 `nmake -f makefile.msc check` or `make -f makefile.mingw check`.
26
27 If you would want to use the cygwin tools to generate executables that
28 *do* use the cygwin runtime, the normal Unix configuration method
29 should work as if on Unix. But it won't produce DLLs. At least I
30 haven't succeeded in that. Also, I have no idea what changes are
31 necessary to the code for it to run successfully on cygwin.
32
33 With a little work, it might be possible to use the ./configure
34 mechanism also with a "mingw32" configuration.
35
36 The following preprocessor macro are used for conditional compilation
37 related to Win32:
38
39 - G_OS_WIN32 is defined when compiling for Win32, *and* without
40   any POSIX emulation, other that to the extent provided by the
41   bundled Microsoft C library (msvcrt.dll) and the pthreads-win32
42   library. For instance, pathnames are in the native Windows syntax.
43
44 - _WIN32 is defined by the compiler
45
46 The Win32 port uses the combination with both of those on. As
47 G_OS_WIN32 is defined in glibconfig.h, it is available to all source
48 files that use GLib (or GTk+, which uses GLib).
49
50 Additionally, there are the compiler-specific macros:
51 - _MSC_VER is defined when using the Microsoft compiler
52 - __GNUC__ is defined when using GCC
53
54 Some of the usage of these macros used to be a bit mixed up, and had
55 to be straightened out when adding the gcc support. In particular, I
56 used to check for _MSC_VER in some places where I really wanted to
57 check for the Microsoft C library, and those checks has now been
58 changed to G_OS_WIN32.
59
60 G_OS_WIN32 implies using the Microsoft C runtime MSVCRT.DLL.
61
62 Building software that use GLib or GTk+
63 =======================================
64
65 Unfortunately, even building software that just *use* GLib or GTk+
66 also require to have the right compiler set up the right way, so if
67 you intend to use gcc, follow the relevant instructions below in that
68 case, too.
69
70 Pthreads library
71 ================
72
73 Before building you must get the pthreads library for Win32 from
74 http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32
75 snapshot from 1999-05-30 is the one that should be used. Edit the
76 location of the pthreads library and include files in makefile.msc or
77 makefile.mingw. The pthreads distribution includes the precompiled dll
78 and import libraries both for MSVC and gcc.
79
80 The pthreads for Win32 package that the thread support uses supposedly
81 isn't quite ready yet, and thus threads stuff should not be relied
82 upon for anything serious.
83
84 Where are the makefiles?
85 ========================
86
87 If you are building from a CVS snapshot, you will not have any
88 makefile.mingw or makefile.msc file. You should copy the corresponding
89 makefile.mingw.in or makefile.msc.in file to that name, and edit the
90 line that sets GLIB_VER to the correct version number.
91
92 This is done automatically when an official distribution package is
93 built.
94
95 Building with gcc
96 =================
97
98 I use the latest and greatest gcc, gcc-2.95.2. 2.95 will also work.
99 Earlier version might, but you are on your own.
100
101 You can either use gcc running on cygwin, or the "pure" mingw
102 gcc. Using the latter is much easier. 
103
104 Just fetch the latest version of gcc for mingw and the msvcrt runtime,
105 currently from
106 ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1/
107 .
108
109 Download the three zip archives: the gcc-<version>-msvcrt,
110 mingw-msvcrt-<timestamp> and binutils-<timestamp>-msvcrt, and unpack
111 them in a suitable directory.
112
113 Set up your PATH so that the gcc from the bin directory that got
114 created above is the one that gets used. You can skip steps 1--5
115 below. Even if you run the mingw gcc, you still want to have cygwin to
116 run make in.
117
118 If you want to run a cygwin-based gcc, it gets much more
119 complicated. We still want gcc to produce code that does not use
120 cygwin, but the msvcrt runtime. The way to do this can be quite
121 complex, and the instructions are not included here. Contact me if you
122 want some possibly outdated, misleading and incomplete advice.
123
124 Building with MSVC
125 ==================
126
127 If using the Microsoft toolchain, build with `nmake -f
128 makefile.msc`. Install with `nmake -f makefile.msc install`. 
129
130 --Tor Lillqvist <tml@iki.fi>