xref: /glogg/INSTALL.win.md (revision 26ec69f124639422f1f9519002b2b651097f3c21)
1*26ec69f1SNicolas Bonnefon# Building glogg for Windows
2*26ec69f1SNicolas Bonnefon
3*26ec69f1SNicolas BonnefonAs often on Windows, building _glogg_ is more complicated than we would like.
4*26ec69f1SNicolas BonnefonThe method we use to test and generate the builds available on
5*26ec69f1SNicolas Bonnefonglogg.bonnefon.org is to cross-build _glogg_ from a Debian/Ubuntu machine.
6*26ec69f1SNicolas Bonnefon
7*26ec69f1SNicolas BonnefonThe compiler currently used is MinGW-W64 4.6.3, which is available on Debian unstable and Ubuntu 12.04 LTS:
8*26ec69f1SNicolas Bonnefon
9*26ec69f1SNicolas Bonnefon    apt-get install g++-mingw-w64-i686
10*26ec69f1SNicolas Bonnefon
11*26ec69f1SNicolas BonnefonThere are two dependencies that must be built for Windows:
12*26ec69f1SNicolas Bonnefon - Qt, we currently use version 4.8.2
13*26ec69f1SNicolas Bonnefon - Boost, we currently use version 1.50.0
14*26ec69f1SNicolas Bonnefon
15*26ec69f1SNicolas BonnefonOnce the dependencies are installed (see below), a script takes care of the building and the packaging:
16*26ec69f1SNicolas Bonnefon
17*26ec69f1SNicolas Bonnefon    ./release-win32-x.sh
18*26ec69f1SNicolas Bonnefon
19*26ec69f1SNicolas Bonnefon## Building Qt on Windows
20*26ec69f1SNicolas Bonnefon
21*26ec69f1SNicolas BonnefonIt is allegedly possible to cross-compile Qt from Windows but after a lot of
22*26ec69f1SNicolas Bonnefonfrustration, the _glogg_ team is building it natively on Windows (using a
23*26ec69f1SNicolas BonnefonWindows 7 64bit VM in VirtualBox) and then using the binary generated from the
24*26ec69f1SNicolas BonnefonLinux machine.  Amazingly, it works as long as we are using a similar version
25*26ec69f1SNicolas Bonnefonof gcc (MinGW-W64) on both machines.
26*26ec69f1SNicolas Bonnefon
27*26ec69f1SNicolas BonnefonHere are instructions to do the build in a Windows 7 VM:
28*26ec69f1SNicolas Bonnefon
29*26ec69f1SNicolas Bonnefon - Download the source from qt website (tested 4.8.2), be sure to download it with DOS end-of-line conventions (zip archive instead of tar.bz2 or tar.gz).
30*26ec69f1SNicolas Bonnefon - Install mingw-w64 from TDM-GCC (tdm64-gcc, tested with 4.6.1).
31*26ec69f1SNicolas Bonnefon - Extract the Qt source in c:\qt\4.8.2
32*26ec69f1SNicolas Bonnefon
33*26ec69f1SNicolas BonnefonIf building a 32 bits version of Qt (what we do for _glogg_):
34*26ec69f1SNicolas Bonnefon
35*26ec69f1SNicolas Bonnefon - Modify qt/4.8.2/mkspecs/win32-g++/qmake.conf to add `-m32` to `QMAKE_CCFLAGS` and `QMAKE_LFLAGS`
36*26ec69f1SNicolas Bonnefon - Modify qt/4.8.2/mkspecs/win32-g++/qmake.conf to replace: `QMAKE_RC = windres -F pe-i386`
37*26ec69f1SNicolas Bonnefon - (optionally make other changes here to improve performances)
38*26ec69f1SNicolas Bonnefon
39*26ec69f1SNicolas BonnefonBuild from the MinGW command prompt:
40*26ec69f1SNicolas Bonnefon
41*26ec69f1SNicolas Bonnefon    configure.exe -platform win32-g++-4.6 -no-phonon -no-phonon-backend -no-webkit -fast -opensource -shared -no-qt3support -no-sql-sqlite -no-openvg -no-gif -no-opengl -no-scripttools
42*26ec69f1SNicolas Bonnefon    mingw32-make
43*26ec69f1SNicolas Bonnefon
44*26ec69f1SNicolas Bonnefon - copy the whole `qt/4.8.2` to the linux machine in `~/qt-x-win32/qt_win/4.8.2`
45*26ec69f1SNicolas Bonnefon
46*26ec69f1SNicolas Bonnefon### Creating the cross-compiled Qt target
47*26ec69f1SNicolas Bonnefon
48*26ec69f1SNicolas Bonnefon - Install ~/qt-x-win32 created before
49*26ec69f1SNicolas Bonnefon
50*26ec69f1SNicolas BonnefonThen create a copy of the standard gcc target to create the new cross-gcc target:
51*26ec69f1SNicolas Bonnefon
52*26ec69f1SNicolas Bonnefon    cd /usr/share/qt4/mkspecs/
53*26ec69f1SNicolas Bonnefon    sudo cp -a win32-g++ win32-x-g++
54*26ec69f1SNicolas Bonnefon
55*26ec69f1SNicolas Bonnefonand modify it to point to the cross-compiler and our local version of Windows Qt:
56*26ec69f1SNicolas Bonnefon
57*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/ (gcc|g\+\+)/ i686-w64-mingw32-\1/' win32-x-g++/qmake.conf
58*26ec69f1SNicolas Bonnefon    sudo sed -i -re '/QMAKE_SH/iQMAKE_SH=1' win32-x-g++/qmake.conf
59*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/QMAKE_COPY_DIR.*$/QMAKE_COPY_DIR = cp -r/' win32-x-g++/qmake.conf
60*26ec69f1SNicolas Bonnefon    sudo sed -i -re '/QMAKE_LFLAGS/s/$/ -mwindows/' win32-x-g++/qmake.conf
61*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/QMAKE_RC.*$/QMAKE_RC = i686-w64-mingw32-windres/' win32-x-g++/qmake.conf
62*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/QMAKE_STRIP\s.*$/QMAKE_STRIP = i686-w64-mingw32-strip/' win32-x-g++/qmake.conf
63*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/\.exe//' win32-x-g++/qmake.conf
64*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/QMAKE_INCDIR\s.*$/QMAKE_INCDIR = \/usr\/i686-w64-mingw32\/include/' win32-x-g++/qmake.conf
65*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/QMAKE_INCDIR_QT\s.*$/QMAKE_INCDIR_QT = \/home\/$USER\/qt_win\/4.8.2\/include/' win32-x-g++/qmake.conf
66*26ec69f1SNicolas Bonnefon    sudo sed -i -re 's/QMAKE_LIBDIR_QT\s.*$/QMAKE_LIBDIR_QT = \/home\/$USER\/qt_win\/4.8.2\/lib/' win32-x-g++/qmake.conf
67*26ec69f1SNicolas Bonnefon
68*26ec69f1SNicolas BonnefonNow you can build a hello world to test Qt:
69*26ec69f1SNicolas Bonnefon
70*26ec69f1SNicolas Bonnefon    mkdir /tmp/testqt
71*26ec69f1SNicolas Bonnefon    cd /tmp/testqt
72*26ec69f1SNicolas Bonnefon    echo '#include <QApplication>
73*26ec69f1SNicolas Bonnefon     #include <QPushButton>
74*26ec69f1SNicolas Bonnefon
75*26ec69f1SNicolas Bonnefon     int main(int argc, char *argv[])
76*26ec69f1SNicolas Bonnefon     {
77*26ec69f1SNicolas Bonnefon         QApplication app(argc, argv);
78*26ec69f1SNicolas Bonnefon
79*26ec69f1SNicolas Bonnefon         QPushButton hello("Hello world!");
80*26ec69f1SNicolas Bonnefon         hello.resize(100, 30);
81*26ec69f1SNicolas Bonnefon
82*26ec69f1SNicolas Bonnefon         hello.show();
83*26ec69f1SNicolas Bonnefon         return app.exec();
84*26ec69f1SNicolas Bonnefon     }' >main.cpp
85*26ec69f1SNicolas Bonnefon    qmake -project
86*26ec69f1SNicolas Bonnefon    qmake -spec win32-x-g++ -r CONFIG+=release
87*26ec69f1SNicolas Bonnefon    make
88*26ec69f1SNicolas Bonnefon
89*26ec69f1SNicolas Bonnefon## Building Boost on Windows
90*26ec69f1SNicolas Bonnefon
91*26ec69f1SNicolas BonnefonDownload the source from boost.org (tested with 1.50.0), DOS EOL mandatory!
92*26ec69f1SNicolas Bonnefon
93*26ec69f1SNicolas BonnefonExtract it in a Windows VM
94*26ec69f1SNicolas Bonnefon
95*26ec69f1SNicolas BonnefonEdit bootstrap.bat to read:
96*26ec69f1SNicolas Bonnefon
97*26ec69f1SNicolas Bonnefon    call .\build.bat mingw %*...
98*26ec69f1SNicolas Bonnefon    set toolset=gcc
99*26ec69f1SNicolas Bonnefon
100*26ec69f1SNicolas BonnefonAnd from the MinGW prompt:
101*26ec69f1SNicolas Bonnefon
102*26ec69f1SNicolas Bonnefon    bootstrap
103*26ec69f1SNicolas Bonnefon    b2 toolset=gcc address-model=32 variant=debug,release link=static,shared threading=multi install
104*26ec69f1SNicolas Bonnefon
105*26ec69f1SNicolas Bonnefon - Copy the whole c:\boost_1_50_0 to the linux machine to ~/qt-x-win32/boost_1_50_0
106*26ec69f1SNicolas Bonnefon
107*26ec69f1SNicolas Bonnefon## (optional) Install NSIS
108*26ec69f1SNicolas Bonnefon
109*26ec69f1SNicolas BonnefonIf _wine_ and the NSIS compiler (available from [here](http://nsis.sourceforge.net/Main_Page)) are available, the script will generate the installer for _glogg_.
110*26ec69f1SNicolas Bonnefon
111*26ec69f1SNicolas BonnefonThe NSIS compiler should be installed in `~/qt-x-win32/NSIS`.
112*26ec69f1SNicolas Bonnefon
113*26ec69f1SNicolas Bonnefon## Building _glogg_
114*26ec69f1SNicolas Bonnefon
115*26ec69f1SNicolas BonnefonFrom this point, building _glogg_ is hopefully straightforward:
116*26ec69f1SNicolas Bonnefon
117*26ec69f1SNicolas Bonnefon    ./release-win32-x.sh
118*26ec69f1SNicolas Bonnefon
119*26ec69f1SNicolas BonnefonThe `release-win32-x.sh` script might need some changes if you use different paths for the dependencies.
120*26ec69f1SNicolas Bonnefon
121*26ec69f1SNicolas BonnefonThe object file is in `./release/`
122