Following the instructions here
http://sourceforge.net/project/shownotes.php?release_id=318305
on how to build the Qt/WinFree sources for Windows using a MinGW
cross-compiler on Linux.

Grab the Mingw X-Compiler rpms from http://mirzam.it.vu.nl/mingw/

Personally, I just wrote a little script to grab the binary rpms
for Fedora Core 3. However, the page also explains how to build
binary rpms from the src rpms.

    $ sh download.sh
    $ cat download.sh
    #! /bin/sh
    
    baseurl=http://mirzam.it.vu.nl/mingw/packages/fc3/
    
    for file in \
    mingw-binutils-2.15.91-7hl.i386.rpm \
    mingw-gcc-core-3.4.2-10hl.i386.rpm \
    mingw-runtime-3.7-11hl.i386.rpm \
    mingw-w32api-3.2-11hl.i386.rpm
    do
    	url=${baseurl}${file}
    	wget ${url}
    done
    
Installing them with:
    $ sh install.sh
    $ cat install.sh
    #! /bin/sh
    
    for file in \
    mingw-binutils-2.15.91-7hl.i386.rpm \
    mingw-gcc-core-3.4.2-10hl.i386.rpm \
    mingw-runtime-3.7-11hl.i386.rpm \
    mingw-w32api-3.2-11hl.i386.rpm
    do
    	rpm -Uvh $file
    done

This installs the MinGW binutils as
    /usr/local/i386-mingw32/bin/
        ar
        as
        dlltool
        ld
        ...
    
The MinGW runtime and w32api are installed as
    /usr/local/i386-mingw32/
        bin/
        include/
        lib/
    
The gcc cross compiler is installed as
    /usr/local/bin/
        i386-mingw32-cpp
        i386-mingw32-gcc
        i386-mingw32-gcc-3.4.2
        i386-mingw32-gccbug
        i386-mingw32-gcov

Bugger. No c++ compiler. I grabbed it from
    http://bitwalk.hp.infoseek.co.jp/src/gcc-mingw32-3.4.2-4.i386.rpm
    
Download the Qt/Win free sources.
Press return when prompted for the password:
    $ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/kde-cygwin \
          login
    $ cvs -z3 -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/kde-cygwin \
          checkout -d qt3 -r QT_WIN32_3_3_BRANCH qt-3

Copy this directory so that we can build the patched version of qmake
for linux. In all:
    $ cp -r qt3 qt3-linux
    $ cd qt3-linux
    $ export QTDIR=$PWD
    $ export QMAKESPEC=linux-g++
    $ export PATH_SAFE=$PATH
    $ export PATH=$PWD/bin:$PATH
    $ make -f Makefile.cvs
    $ ./configure -no-cups -thread -platform $QMAKESPEC -shared
    $ export PATH=$PATH_SAFE

Make the just-compiled qmake available to the cross-compiled tree.
Try and use the standard moc and uic from a conventional FC3 rpm.
    $ cd ../qt3/bin
    $ ln -s ../../qt3-unix/bin/qmake .
    $ ln -s /usr/bin/moc .
    $ ln -s /usr/bin/uic .

Check whether the cross-compilation tools in
qt3/mkspecs/win32-g++-cross/qmake.conf are named correctly.
Specifcally, I had to change the
QMAKE_CC, QMAKE_CXX, QMAKE_LINK, QMAKE_LIB, QMAKE_RC and QMAKE_STRIP entries.

Create .qtwinconfig because otherwise qmake creates exe's with a
dll extension.

    $ echo '
    win32-g++:contains(TEMPLATE,lib) {
        contains(CONFIG,shared) {
        CONFIG += dll
        }
    }' > qt3/.qtwinconfig

Configure:
    $ cd qt3
    $ export QTDIR=$PWD
    $ export QMAKESPEC=win32-g++-cross
    $ export PATH_SAFE=$PATH
    $ export PATH=$PWD/bin:$PATH
    $ make -f Makefile.cvs
    $ ./configure -no-cups -platform win32-g++-cross -shared

I found that I had to patch two of the i386-mingw header files:
    $ cd /usr/local/lib/gcc/i386-mingw32/3.4.2/include/ && \
      diff -u float_orig.h float.h
    @@ -160,4 +160,6 @@
    
     #endif /* C99 */
    
    +#include_next <float.h>
    +
     #endif /* _FLOAT_H___ */

    $ cd /usr/local/i386-mingw32/include && \
      diff -u float_orig.h float.h
    @@ -16,7 +16,7 @@
      *
      */
    
    -#include_next<float.h>
    +//#include_next<float.h>
    
    
    #ifndef _MINGW_FLOAT_H_

Compilation finds the 3.4.2 version first, so I had to explicitly
#include_next the Windows extras in /usr/local/i386-mingw32/include/float.h,
rather than the other way around.


Edit .qmake.cache and replace the term 'dll' with 'shared' in the
CONFIG=.. line  [1]

Build the library:
    $ make
    $ export PATH=$PATH_SAFE

It takes about 50 mins to build libqt3.dll from scratch on this 2.67GHz
machine. Thereafter, I could build the entire Qt tree once a couple of
issues had been resolved by Ralf Habacker on the mailing list.

With many thanks to Ralf.

Angus Leeming 21 April 2005.
