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