fix docs; they said we validated the UTF-8, but we can't possibly detect
[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 If you would want to use the cygwin tools to generate a GLib that
28 *does* use the cygwin runtime, the normal Unix configuration method
29 should work as if on Unix. Note that successfully producing shared
30 libraries (DLLs) most probably requires you to have a very new libtool
31 (from March 2001), and to replace the libtool.m4 included in
32 acinclude.m4 with the new one, and to replace ltmain.sh.
33
34 It is also possible to use the ./configure mechanism when building for
35 a mingw configuration. You should be running cygwin for the configure
36 script to work, obviously. The same libtool issue has to be taken into
37 account as when building for Cygwin: You most probably should have a
38 libtool from March 2001 or so, and replace libtool.m4 (in
39 acinclude.m4) and ltmain.sh.
40
41 The following preprocessor macros are used for conditional compilation
42 related to Win32:
43
44 - G_OS_WIN32 is defined when compiling for Win32, *and* without
45   any POSIX emulation, other that to the extent provided by the
46   bundled Microsoft C library (msvcrt.dll) and the pthreads-win32
47   library. For instance, pathnames are in the native Windows syntax.
48
49 - G_WITH_CYGWIN is defined if compiling for the Cygwin
50   environment. Note that G_OS_WIN32 is *not* defined in that case, as
51   Cygwin is supposed to behave like Unix. G_OS_UNIX *is* defined when
52   compiling for Cygwin.
53
54 - G_PLATFORM_WIN32 is defined when either G_OS_WIN32 or G_WITH_CYGWIN
55   is defined.
56
57 The Win32 port of GLib and related software uses only G_OS_WIN32. As
58 G_OS_WIN32 is defined in glibconfig.h, it is available to all source
59 files that use GLib (or GTk+, which uses GLib).
60
61 Additionally, there are the compiler-specific macros:
62 - __GNUC__ is defined when using GCC
63 - _MSC_VER is defined when using the Microsoft compiler
64
65 G_OS_WIN32 implies using the Microsoft C runtime MSVCRT.DLL. GLib or
66 software using it is not known to work with the older CRTDLL.DLL
67 runtime.
68
69 Building software that use GLib or GTk+
70 =======================================
71
72 Even building software that just *use* GLib or GTk+ also require to
73 have the right compiler set up the right way, so if you intend to use
74 gcc, follow the relevant instructions below in that case, too.
75
76 Pthreads library
77 ================
78
79 Before building you must get the pthreads library for Win32 from
80 http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32
81 snapshot from 1999-05-30 is the one that should be used. Edit the
82 location of the pthreads library and include files in makefile.msc or
83 makefile.mingw. The pthreads distribution includes the precompiled dll
84 and import libraries both for MSVC and gcc. Later versions might also
85 work.
86
87 The pthreads for Win32 package that the thread support uses supposedly
88 isn't quite ready yet, and thus threads stuff should not be relied
89 upon for anything serious.
90
91 Libiconv
92 ========
93
94 Before building GLib you must also have the libiconv library, either
95 from the same website mentioned above, or from it's homepage at
96 http://clisp.cons.org/~haible/packages-libiconv.html.
97
98 Where are the makefiles?
99 ========================
100
101 If you are building from a CVS snapshot, you will not have any
102 makefile.mingw or makefile.msc file. You should copy the corresponding
103 makefile.mingw.in or makefile.msc.in file to that name, and edit the
104 line that sets GLIB_VER to the correct version number.
105
106 This is done automatically when an official GLib source distribution
107 package is built.
108
109 Building GLib with gcc
110 ======================
111
112 I use the latest gcc, gcc-2.95.2. Version 2.95 will most probably also
113 work.
114
115 You can either use gcc running on cygwin, or the "pure" mingw
116 gcc. Using the latter is much easier. 
117
118 Just fetch the latest version of gcc for mingw and the msvcrt runtime,
119 currently from
120 ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1/
121 .
122
123 Download the three zip archives: the gcc-<version>-msvcrt,
124 mingw-msvcrt-<timestamp> and binutils-<timestamp>-msvcrt, and unpack
125 them in a suitable directory.
126
127 Set up your PATH so that the gcc from the bin directory that got
128 created above is the one that gets used. You can skip steps 1--5
129 below. Even if you run the mingw gcc, you still want to have cygwin to
130 run make in.
131
132 If you want to run a cygwin-based gcc, it gets a bit more
133 complicated. We still want gcc to produce code that does not use
134 cygwin, but the msvcrt runtime. The way to do this can be quite
135 complex, and the instructions are not included here. Contact me if you
136 want some possibly outdated, misleading and incomplete advice.
137
138 Building with MSVC
139 ==================
140
141 If using the Microsoft toolchain, build with `nmake -f
142 makefile.msc`. Install with `nmake -f makefile.msc install`. 
143
144 --Tor Lillqvist <tml@iki.fi>