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.
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 updated makefile.msc files to the
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 I also use the -fnative-struct flag, which means that in order to use
24 the prebuilt DLLs (especiall of GTK+), you *must* also use that flag.
25 (This flag means that the struct layout is identical to that used by
28 To test the GLib functions, go to the tests subdirectory and enter
29 `nmake -f makefile.msc check` or `make -f makefile.mingw check`.
31 If you would want to use the cygwin tools to generate executables that
32 *do* use the cygwin runtime, the normal Unix configuration method
33 should work as if on Unix. But it won't produce DLLs. At least I
34 haven't succeeded in that. Also, I have no idea what changes are
35 necessary to the code for it to run successfully on cygwin.
37 With a little work, it might be possible to use the ./configure
38 mechanism also with a "mingw32" configuration.
40 The following preprocessor macro are used for conditional compilation
43 - G_OS_WIN32 is defined when compiling for Win32, *and* without
44 any POSIX emulation, other that to the extent provided by the
45 bundled Microsoft C library (msvcrt.dll) and the pthreads-win32
46 library. For instance, pathnames are in the native Windows syntax.
48 - _WIN32 is defined by the compiler
50 The Win32 port uses the combination with both of those on. As
51 G_OS_WIN32 is defined in glibconfig.h, it is available to all source
52 files that use GLib (or GTk+, which uses GLib).
54 Additionally, there are the compiler-specific macros:
55 - _MSC_VER is defined when using the Microsoft compiler
56 - __GNUC__ is defined when using GCC
58 Some of the usage of these macros used to be a bit mixed up, and had
59 to be straightened out when adding the gcc support. In particular, I
60 used to check for _MSC_VER in some places where I really wanted to
61 check for the Microsoft C library, and those checks has now been
62 changed to G_OS_WIN32.
64 G_OS_WIN32 implies using the Microsoft C runtime MSVCRT.DLL.
66 Building software that use GLib or GTk+
67 =======================================
69 Unfortunately, even building software that just *use* GLib or GTk+
70 also require to have the right compiler set up the right way, so if
71 you intend to use gcc, follow the relevant instructions below in that
77 Before building you must get the pthreads library for Win32 from
78 http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32
79 snapshot from 1999-05-30 is the one that should be used. Edit the
80 location of the pthreads library and include files in makefile.msc or
81 makefile.mingw. The pthreads distribution includes the precompiled dll
82 and import libraries both for MSVC and gcc.
84 The pthreads for Win32 package that the thread support uses supposedly
85 isn't quite ready yet, and thus threads stuff should not be relied
86 upon for anything serious.
88 Where are the makefiles?
89 ========================
91 If you are building from a CVS snapshot, you will not have any
92 makefile.mingw or makefile.msc file. You should copy the corresponding
93 makefile.mingw.in or makefile.msc.in file to that name, and edit the
94 line that sets GLIB_VER to the correct version number.
96 This is done automatically when an official distribution package is
102 I use the latest and greatest gcc, gcc-2.95.2. 2.95 will also work.
103 Earlier version might, but you are on your own.
105 You can either use gcc running on cygwin, or the "pure" mingw
106 gcc. Using the latter is much easier.
108 Just fetch the latest version of gcc for mingw and the msvcrt runtime,
110 ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1/
113 Download the three zip archives: the gcc-<version>-msvcrt,
114 mingw-msvcrt-<timestamp> and binutils-<timestamp>-msvcrt, and unpack
115 them in a suitable directory.
117 Set up your PATH so that the gcc from the bin directory that got
118 created above is the one that gets used. You can skip steps 1--5
119 below. Even if you run the mingw gcc, you still want to have cygwin to
122 If you want to run a cygwin-based gcc, it gets much more
123 complicated. We still want gcc to produce code that does not use
124 cygwin, but the msvcrt runtime. The way to do this can be quite
125 complex, and the instructions are not included here. Contact me if you
126 want some possibly outdated, misleading and incomplete advice.
131 If using the Microsoft toolchain, build with `nmake -f
132 makefile.msc`. Install with `nmake -f makefile.msc install`.
134 --Tor Lillqvist <tml@iki.fi>