Notes for cross-compiling webkit on amd64-debian to win32 using mingw32 ----------------------------------------------------------------------- This is a complete pain in the ass set of notes for cross-compiling the libraries and the dependencies for webkit. Compilation is actually surprisingly quick (unlike native compiling on win32 using mingw32) but it's finding the dependencies and getting them all useable that's the complete pain. Installing the compiler ----------------------- You're not going to quite believe this, but literally at the time of writing a critical patch was made to gcc which provided support for c++ exceptions across dll boundaries: yes, folks, you need gcc 4.4.0 right out of the latest gcc.gnu.org svn repository. i recommend you use the git mirror instead. i decided to keep the debian mingw32-runtime, and the mingw32-binutils, then, after successfully following the step of cross-compiling the replacement compiler, i removed the debian mingw32-binutils package and cross-compiled a replacement for that. ...actually i think what i did was apt-get source mingw32-binutils to save looking up where to get binutils. so, rather than run the entire MingwCrossCompile script, i missed out a step (the binutils download and build). i seem to remember compiling and installing the compiler twice. first time only installed a few bits; second time seemed to install some more. you're better off looking for really authoritative instructions: most of what i've done is by a process of osmosis, late at night :) oh - yes: i remember: the first time i did this: #!/bin/sh mkdir build cd build && ../configure -v \ --prefix=/usr \ --target=i586-mingw32msvc \ --enable-languages=c,c++ \ --disable-win32-registry --without-x \ --enable-threads \ --enable-sjlj-exceptions \ --with-gcc --with-gnu-ld --with-gnu-as \ --enable-version-specific-runtime-libs \ --with-headers="/usr/i586-mingw32msvc/include" which was really odd cos it jammed a load of header files into the build/ directory and the second time i did this: #!/bin/sh mkdir build cd build && ../configure -v \ --prefix=/usr \ --target=i586-mingw32msvc \ --enable-languages=c,c++ \ --disable-win32-registry --without-x \ --enable-threads \ --enable-sjlj-exceptions \ --with-gcc --with-gnu-ld --with-gnu-as \ --enable-version-specific-runtime-libs and that seemed to "do the trick". then i could move on to cross-compiling mingw32-binutils, without which i quickly discovered that the compilation of webkit utterly barfed. why did i do this, instead of use gcc-3.4.5? -lgcc_s, remember, and, also, i was being lied to by the linker, which was barfing on the msvc-compiled icu3.8 libs. some people will desperately try anything just to meander drunkenly towards a workable solution.... ... dat's me! Installing the dependencies --------------------------- as you go along, pkg-config provides each dependent library with the --cflags and --libs of its dependency packages. tml's .pc files, which you will find (given my choice of directory) in /opt/cross-tools/mingw32/lib/pkgconfig, contain a prefix that needs to be edited. change it to /opt/cross-tools/mingw32. just a word of caution: various bits of advice you may see tell you to DELETE things other than what you don't need. you may believe that things in share/ and etc/ aren't needed, and that you only need the stuff from include/ lib/ bin/ etc. well, i got news: you're going to need the etc/gtk* etc/fonts/ and other bits for running under wine or even windows - so don't delete them yet (like i nearly did). 0) pick a directory, any directory: i chooose..... /opt/cross-tools 1) create /opt/cross-tools and /opt/cross-tools/mingw32 2) apt-get install wine 3) apt-get install ccache mingw32 - make sure it's 3.4.5 because at time of writing (09sep2008) -lgcc_s isn't supported. see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451458 for details, including a link to a patch if you're mad enough to compile mingw32 yourself). i decided to give the entire gcc source download thing a go (see above) after too many link failures to be able to rule out -lgcc_s as the cause. gcc 3.4.5 _might_ work for you - 4.0 4.1, 4.2, 4.3 and 4.4 prior to the above-referenced svn commit (about 07sep2009) will NOT work, guaranteed. 4) unpack all the libraries in /opt/cross-tools/mingw32 according to http://gcam.js.cx/index.php/MinGW_MSys_GTK_Configuration_Guide 5) put the following into /opt/cross-tools/environ.src and execute it source /opt/cross-tools/environ.src PREFIX=/opt/cross-tools TARGET=mingw32 #export CC="/opt/cross-tools/bin/i386-mingw32-gcc" #export CXX="/opt/cross-tools/bin/i386-mingw32-g++" export CC="/usr/lib/ccache/i586-mingw32msvc-gcc" export DLLTOOL="i586-mingw32msvc-dlltool" export CXX="/usr/lib/ccache/i586-mingw32msvc-g++" export CFLAGS="-O2 -march=i586 -mms-bitfields -I/opt/cross-tools/mingw32/include " export CXXFLAGS="-O2 -march=i586 -mms-bitfields" export PKG_CONFIG_PATH=$PREFIX/$TARGET/lib/pkgconfig export PATH=$PREFIX/bin:$PREFIX/$TARGET/bin:/bin:/usr/bin export LD_LIBRARY_PATH=$PREFIX/$TARGET/lib export LDFLAGS=-L$PREFIX/$TARGET/lib #export OBJDUMP=$PREFIX/bin/i386-mingw32-objdump export OBJDUMP=/usr/bin/i586-mingw32msvc-objdump export HOST_CC=/usr/bin/gcc 6) put the following into /usr/bin/cross-configure.sh: #!/bin/sh #export PKG_CONFIG=/opt/cross-tools/bin/pkg-config export PKG_CONFIG=/usr/bin/pkg-config export FREETYPE_CONFIG=/opt/cross-tools/bin/freetype-config CONFIG_SHELL=/bin/sh export CONFIG_SHELL PREFIX=/opt/cross-tools TARGET=i586-mingw32msvc PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" export PATH if [ -f "$PREFIX/$TARGET/bin/$TARGET-sdl-config" ]; then SDL_CONFIG="$PREFIX/$TARGET/bin/$TARGET-sdl-config" export SDL_CONFIG fi cache=cross-config.cache sh ./configure --cache-file="$cache" \ --target=$TARGET --host=$TARGET --build=i386-linux \ $* status=$? rm -f "$cache" exit $status 7) get a whole stack of libraries from here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451458 i think i got the following, including the -devs, but there may be more, or updates from different locations: zlib-1.2.3 pkg-config-0.23 libpng-1.2.8 libiconv-1.9.1.bin.woe32.zip gettext-0.14.5 fontconfig-2.4.2-tml-20071015.zip and the fontconfig-dev as well cairo from there didn't cut the mustard: i built from source (see below) which didn't take long. 8) get cairo 1.6.4 and pixman-0.11.10: http://www.cairographics.org/releases/ 9) get pthreads-win32 libs, dlls and header files, and install the buggers manually. packages - not even a .zip file - could be found. stuff things into /opt/cross-tools/mingw32/lib and include as appropriate, but then note the --disable-pthreads etc. below so you _might_ be able to get away with avoiding pthreads entirely. i got it as part of the ongoing mess. 10) get more stuff from here: http://sourceforge.net/project/showfiles.php?group_id=16768 i think i got fontconfig, libiconv and friends from there. 11) more stuff - possibly: http://sourceforge.net/project/showfiles.php?group_id=16768 dependencies (which look a bit messy around the pango / cairo area): *) expat-2.0.1 cross-configure.sh --prefix=/opt/cross-tools/mingw32/ --without-x --disable-xlib --enable-png --enable-freetype2 --disable-static --enable-shared=yes --disable-python --without-python --without-threads --without-crypto *) fontconfig-2.4.2 tml version * freetype2 9.16.3 (goes by different numbering for win32) gnu / tml version * svg (not installed) * pixman-0.10.0 - gtk * cairo-1.6.4 - svg, freetype2, fontconfig, pixman http://bugs.winehq.org/show_bug.cgi?id=7186 reeeeeead iiiiit. if you want to run under Wine (i do), patch the file: src/cairo-win32-private.h /* AAU: hack #define WIN32_FONT_LOGICAL_SCALE 32 */ #define WIN32_FONT_LOGICAL_SCALE 1 cross-configure.sh --prefix=/opt/cross-tools/mingw32/ --without-x --disable-xlib --enable-png --enable-freetype2 --disable-static --enable-shared=yes --disable-python --without-python --disable-pthread --disable-gtk-doc *) pango-1.0-1.20.5 - cairo, freetype2, fontconfig cross-configure.sh --prefix=/opt/cross-tools/mingw32/ --without-x --disable-xlib --enable-png --enable-freetype2 --disable-static --enable-shared=yes --disable-python --without-python --disable-pthread --disable-gtk-doc *) curl 7.18.2 - ws2_32, z cross-configure.sh --prefix=/opt/cross-tools/mingw32/ --without-x --disable-xlib --enable-png --enable-freetype2 --disable-static --enable-shared=yes --disable-python --without-python --disable-gtk-doc --disable-pthread --disable-ldap *) icu - do not use win32 version, it will cause a segfault on link. still tracking down issues to cross-compile under mingw32c. i'm declaring a "reasonable" degree of success in cross-compiling, by cheating, and using a combination of host-based use of /usr/sbin/genccomp, a hacked version of /usr/bin/pkgdata to generate makefile fragments with ".dll" instead of ".so", we have this: the config/mh-unknown you will require is here: http://lkcl.net/webkit/icu-3.8.1-config-mhunknown the resultant crap is available here: http://lkcl.net/webkit/icu38.mingw32.tgz do not try this at home. *) libxml2-2.6.32.dfsg - iconv, z, m, ws2_32 cross-configure.sh --prefix=/opt/cross-tools/mingw32/ --without-x --disable-xlib --enable-png --enable-freetype2 --disable-static --enable-shared=yes --disable-python --without-python --disable-gtk-doc --without-threads *) libxslt-1.1.24 - libxml2 DO NOT try to install or use libxslt. cross-configure.sh --prefix=/opt/cross-tools/mingw32/ --without-x --disable-xlib --enable-png --enable-freetype2 --disable-static --enable-shared=yes --disable-python --without-python --disable-gtk-doc --without-threads --without-crypto *) webkit - pangl, icu, curl, libxml2, #xslt1 you can review the monster mess here, which includes the #16401 glib bindings patch. good luck, and have fun sorting out the win32 bits, they should be pretty obvious: search for... err... WIN32! http://lkcl.net/webkit/webkit-win32-glib.patch for cross-configure, use this: #!/bin/sh export FREETYPE_CONFIG=/opt/cross-tools/bin/freetype-config CONFIG_SHELL=/bin/sh export CONFIG_SHELL PREFIX=/opt/cross-tools TARGET=i586-mingw32msvc PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" export PATH if [ -f "$PREFIX/$TARGET/bin/$TARGET-sdl-config" ]; then SDL_CONFIG="$PREFIX/$TARGET/bin/$TARGET-sdl-config" export SDL_CONFIG fi export LDFLAGS="-L$PREFIX/mingw32/lib/ -LWebCore/plugins/win -lwinmm -lz -lpng -lstdc++" export CPPFLAGS="-march=i586 -mms-bitfields -I$PREFIX/mingw32/include -IWebCore/plugins/win -IWebCore/platform" cache=cross-config.cache sh ./configure --cache-file="$cache" --prefix=$PREFIX/mingw32 \ --disable-dashboard-support \ --disable-offline-web-applications --disable-dom-storage \ --disable-database --disable-icon-database --disable-video \ --build=i386-linux --target=$TARGET --host=$TARGET \ --disable-xslt \ --with-target=win32 --disable-svg --with-font-backend=pango \ --enable-shared --disable-static rm -f "$cache" Running under Wine ------------------ Current bug-bear: compilation succeeds but under Wine, the fonts look utterly shit: http://bugs.winehq.org/show_bug.cgi?id=3915 latest versions are actually: http://sourceforge.net/project/shownotes.php?release_id=580615&group_id=235 Use this to install some fonts: http://www.linuxforums.org/forum/wine/111138-fonts-wine.html Also, you will need to configure gtk correctly, and i am presently manually floundering around with three versions of gtk-engines and two of pango modules, trying to work out where everything must go and/or be installed. Ok. 1) Copy the files from Common Files\GTK\*.dll to ~/.wine/drive_c/windows/system 2) Copy the libwebkit-1.0-dll into system directory 3) copy lots more dlls - any you think you'll need and many more that you don't - into system directory 4) copy the Common Files\GTK\etc, share and lib directories into system directory 5) find an etc/fonts subdirectory (i found one from tml's stuff) and copy _that_ into windows/system/etc/fonts. 6) get an /etc/pango/pango.modules file from linux, copy it into windows/system/etc/pango/pango.modules, then hack it up to replace the lib location and lib .so extension to match _your_ location - e.g. Z:/opt/cross-tools/mingw32/lib/gtk... etc. etc. and .dll respectively. 7) make damn sure you compiled libcairo 1.6.4 with that "#define WIN32_FONT_LOGICAL_SCALE 1" terrible hack. this blows goats and will make "pure" windows users want to eat your brain... but you're reading this because... you're not a windows user! N) lots more.