Update. Don't mention pthreads.
[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.
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.3 from www.mingw.org. It might be possible
18 also to use gcc from Cygwin. (But also in that case, we want to use
19 gcc -mno-cygwin, i.e. produce executables (.exe and .dll files) that
20 do *not* require the cygwin runtime library. This is called "mingw".)
21
22 To successfully use gcc, follow the instructions below.  I also use
23 the -fnative-struct flag, which means that in order to use the
24 prebuilt DLLs (especially of GTK+), you *must* also use that flag.
25 (This flag means that the struct layout is identical to that used by
26 MSVC.)
27
28 If you would want to use the Cygwin tools to generate a GLib that
29 *does* use the Cygwin runtime, the normal Unix configuration method
30 should work as if on Unix. Note that successfully producing shared
31 libraries (DLLs) most probably requires you to have a very new
32 libtool. (And a new libtool probably requires rather new autoconf and
33 automake.)
34
35 It might also be possible to use the ./configure mechanism when
36 building for a mingw configuration. You should be running Cygwin for
37 the configure script to work, obviously. The same libtool issue has to
38 be taken into account as when building for Cygwin: You most probably
39 should have a very new libtool.
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 is
66 not known to work with the older CRTDLL.DLL runtime, or the static
67 Microsoft C runtime libraries.
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 Libiconv
77 ========
78
79 Before building GLib you must also have the libiconv library, either
80 from the same website mentioned above, or from it's homepage at
81 http://clisp.cons.org/~haible/packages-libiconv.html. Libiconv has
82 makefiles for building with MS Visual C only, but as it is one source
83 file only, building iot "by hand" with gcc isn't hard.
84
85 Where are the makefiles?
86 ========================
87
88 If you are building from a CVS snapshot, you will not have any
89 makefile.mingw or makefile.msc file. You should copy the corresponding
90 makefile.mingw.in or makefile.msc.in file to that name, and edit the
91 @GLIB_VERSION@ strings to the correct version number.
92
93 This is done automatically when an official GLib source distribution
94 package is built.
95
96 Building GLib with gcc
97 ======================
98
99 I use the latest gcc, gcc-2.95.3. Version 2.95.2 will most probably
100 also work.
101
102 You can either use gcc running on Cygwin, or the "pure" mingw
103 gcc. Using the latter is much easier. 
104
105 Just fetch the latest version of gcc for mingw and the msvcrt runtime,
106 from www.mingw.org..
107
108 Set up your PATH so that the gcc from the bin directory that got
109 created above is the one that gets used. Even if you run the mingw
110 gcc, you still want to have Cygwin to run make in.
111
112 If you want to run a Cygwin-based gcc, it gets a bit more
113 complicated. We still want gcc to produce code that does not use
114 Cygwin, but the msvcrt runtime. In theory it should work to use the
115 -no-cygwin flag, but I haven't tested that lately.
116
117 Building with MSVC
118 ==================
119
120 If using the Microsoft toolchain, build with `nmake -f
121 makefile.msc`.
122
123 --Tor Lillqvist <tml@iki.fi>