1 For more information about the port or GLib, GTk+ and the GIMP to
2 native Windows, and pre-built binary packages, see
3 http://www.iki.fi/tml/gimp/win32/ . "Native" means that we use the
4 Win32 API only, and not any POSIX emulation layer except that provided
5 by the Microsoft runtime C library. Additionally, a pthreads emulation
8 To build GLib on Win32, you can use either the Microsoft compiler and
9 tools, or gcc. Both the compiler from MSVC 5.0 and from MSVC 6.0 have
10 been used successfully. With gcc I mean egcs-1.1.2 (as distributed by
11 Mumit Khan), running under cygwin-b20.1.
13 If you build with gcc, note that the produced executables and DLLs do
14 *not* require the cygwin dll (gcc -mno-cygwin). That's the whole point
15 of this porting effort, more or less.
17 The egcs support was added quite recently, but seems to
18 work. Debugging with gdb works. I prefer to use the msvcrt runtime and
19 not the default crtdll. This can be achieved by applying the following
20 diff to the specs file, which typically is installed as
21 C:/cygnus/cygwin-b20/H-i586-cygwin32/lib/gcc-lib/i586-cygwin32/egcs-2.91.66/specs.
23 Sorry for the illegibility of this diff, but the specs file is like
24 that... This diff replaces -lcrtdll with -lmsvcrt, replaces crt1 with
25 crt2, and defines __MSVCRT__.
27 --- specs.ORIG Sun Apr 25 00:40:40 1999
28 +++ specs Sun Apr 25 00:48:04 1999
30 -%{pg:-lgmon} %{!mno-cygwin:-lcygwin} %{mno-cygwin:-lmingw32 -lmoldname -lcrtdll} %{mwindows:-luser32 -lgdi32 -lcomdlg32} -lkernel32 -ladvapi32 -lshell32
31 +%{pg:-lgmon} %{!mno-cygwin:-lcygwin} %{mno-cygwin:-lmingw32 -lmoldname -lmsvcrt} %{mwindows:-luser32 -lgdi32 -lcomdlg32} -lkernel32 -ladvapi32 -lshell32
33 -%{mdll: %{!mno-cygwin:dllcrt0%O%s} %{mno-cygwin:dllcrt1%O%s}} %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt1%O%s} %{pg:gcrt0%O%s}}
34 +%{mdll: %{!mno-cygwin:dllcrt0%O%s} %{mno-cygwin:dllcrt2%O%s}} %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt2%O%s} %{pg:gcrt0%O%s}}
36 --Di386 -D_WIN32 -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386)
37 +-Di386 -D_WIN32 %{mno-cygwin:-D__MSVCRT__ } -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386)
39 Note: If you build with gcc, you should also fix the definition of
40 _dev_t in the header mingw32/sys/types.h to correspond to what it
41 actually is used by msvcrt.dll. It should be unsigned int, not
42 short. Otherwise stat() calls will fail.
44 Before building you must get the pthreads library for Win32 from
45 http://sourceware.cygnus.com/pthreads-win32/. The pthreads-win32
46 snapshot from 1999-04-07 is the one that should be used. Edit the
47 location of the pthreads library and include files in makefile.msc.
49 If using the Microsoft toolchain, build with `nmake -f
50 makefile.msc`. Install with `nmake -f makefile.msc install`. If using
51 egcs, build using `make -f makefile.cygwin`.
53 To test the GLib functions, go to the tests subdirectory and enter
54 `nmake -f makefile.msc check`.
56 If you would want to use the cygwin tools to generate executables that
57 *do* use the cygwin runtime, the normal Unix configuration method
58 should work as if on Unix (knock on wood).
60 With a little work, it might be possible to use the ./configure
61 mechanism also with a "mingw32" configuration.
63 The following preprocessor macros are used for conditional compilation
66 - WIN32 is defined when compiling for the Win32 platform, regardless
67 if using the X11 or Win32 windowing API (in the case of GLib, this
68 dimension isn't significant), regardless whether using a more or
69 less complete POSIX emulation runtime layer (like Cygwin) or not.
71 - NATIVE_WIN32 is defined when compiling for Win32, *and* without
72 any POSIX emulation, other that to the extent provided by the
73 bundled Microsoft C library and the pthreads-win32 library. For
74 instance, pathnames are in the native Windows syntax.
76 The Win32 port uses the combination with both of those on.
78 Additionally, there are the compiler-specific macros:
79 - _MSC_VER is defined when using the Microsoft compiler
80 - __GNUC__ is defined when using GCC (i.e. egcs)
82 Some of the usage of these macros was a bit mixed up, and had to be
83 straightened out when adding the gcc support. In particular, I used to
84 check for _MSC_VER in some places where I really wanted to check for
85 the Microsoft C library, and those checks has now been changed to
88 The pthreads for Win32 package that the thread support uses isn't
89 quite ready yet, and thus threads really should not be relied upon.