9bd3abeb4b62d27cd3cc8b0bf69a393d6c49d3c5
[platform/upstream/glib.git] / README.win32
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
6 library is used.
7
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.
12
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.
16
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.
22
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__.
26
27 --- specs.ORIG  Sun Apr 25 00:40:40 1999
28 +++ specs       Sun Apr 25 00:48:04 1999
29 @@ -23 +23 @@
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
32 @@ -29 +29 @@
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}}
35 @@ -38 +38 @@
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) 
38
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.
43
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 or
48 makefile.cygwin.
49
50 If using the Microsoft toolchain, build with `nmake -f
51 makefile.msc`. Install with `nmake -f makefile.msc install`.  If using
52 egcs, build using `make -f makefile.cygwin`.
53
54 To test the GLib functions, go to the tests subdirectory and enter
55 `nmake -f makefile.msc check` or `make -f makefile.cygwin check`.
56
57 If you would want to use the cygwin tools to generate executables that
58 *do* use the cygwin runtime, the normal Unix configuration method
59 should work as if on Unix (knock on wood).
60
61 With a little work, it might be possible to use the ./configure
62 mechanism also with a "mingw32" configuration.
63
64 The following preprocessor macros are used for conditional compilation 
65 related to Win32:
66
67 - WIN32 is defined when compiling for the Win32 platform, regardless
68   if using the X11 or Win32 windowing API (in the case of GLib, this
69   dimension isn't significant), regardless whether using a more or
70   less complete POSIX emulation runtime layer (like Cygwin) or not.
71
72 - NATIVE_WIN32 is defined when compiling for Win32, *and* without
73   any POSIX emulation, other that to the extent provided by the
74   bundled Microsoft C library and the pthreads-win32 library. For
75   instance, pathnames are in the native Windows syntax.
76
77 The Win32 port uses the combination with both of those on.
78
79 Additionally, there are the compiler-specific macros:
80 - _MSC_VER is defined when using the Microsoft compiler
81 - __GNUC__ is defined when using GCC (i.e. egcs)
82
83 Some of the usage of these macros was a bit mixed up, and had to be
84 straightened out when adding the gcc support. In particular, I used to
85 check for _MSC_VER in some places where I really wanted to check for
86 the Microsoft C library, and those checks has now been changed to
87 NATIVE_WIN32. NATIVE_WIN32 should maybe be renamed to USE_MSVCRT.
88
89 The pthreads for Win32 package that the thread support uses isn't
90 quite ready yet, and thus threads really should not be relied upon.