xref: /glogg/INSTALL.win.md (revision 26ec69f124639422f1f9519002b2b651097f3c21)
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 mingw-w64 from TDM-GCC (tdm64-gcc, tested with 4.6.1).
31 - Extract the Qt source in c:\qt\4.8.2
32
33If building a 32 bits version of Qt (what we do for _glogg_):
34
35 - Modify qt/4.8.2/mkspecs/win32-g++/qmake.conf to add `-m32` to `QMAKE_CCFLAGS` and `QMAKE_LFLAGS`
36 - Modify qt/4.8.2/mkspecs/win32-g++/qmake.conf to replace: `QMAKE_RC = windres -F pe-i386`
37 - (optionally make other changes here to improve performances)
38
39Build from the MinGW command prompt:
40
41    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    mingw32-make
43
44 - copy the whole `qt/4.8.2` to the linux machine in `~/qt-x-win32/qt_win/4.8.2`
45
46### Creating the cross-compiled Qt target
47
48 - Install ~/qt-x-win32 created before
49
50Then create a copy of the standard gcc target to create the new cross-gcc target:
51
52    cd /usr/share/qt4/mkspecs/
53    sudo cp -a win32-g++ win32-x-g++
54
55and modify it to point to the cross-compiler and our local version of Windows Qt:
56
57    sudo sed -i -re 's/ (gcc|g\+\+)/ i686-w64-mingw32-\1/' win32-x-g++/qmake.conf
58    sudo sed -i -re '/QMAKE_SH/iQMAKE_SH=1' win32-x-g++/qmake.conf
59    sudo sed -i -re 's/QMAKE_COPY_DIR.*$/QMAKE_COPY_DIR = cp -r/' win32-x-g++/qmake.conf
60    sudo sed -i -re '/QMAKE_LFLAGS/s/$/ -mwindows/' win32-x-g++/qmake.conf
61    sudo sed -i -re 's/QMAKE_RC.*$/QMAKE_RC = i686-w64-mingw32-windres/' win32-x-g++/qmake.conf
62    sudo sed -i -re 's/QMAKE_STRIP\s.*$/QMAKE_STRIP = i686-w64-mingw32-strip/' win32-x-g++/qmake.conf
63    sudo sed -i -re 's/\.exe//' win32-x-g++/qmake.conf
64    sudo sed -i -re 's/QMAKE_INCDIR\s.*$/QMAKE_INCDIR = \/usr\/i686-w64-mingw32\/include/' win32-x-g++/qmake.conf
65    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    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
68Now you can build a hello world to test Qt:
69
70    mkdir /tmp/testqt
71    cd /tmp/testqt
72    echo '#include <QApplication>
73     #include <QPushButton>
74
75     int main(int argc, char *argv[])
76     {
77         QApplication app(argc, argv);
78
79         QPushButton hello("Hello world!");
80         hello.resize(100, 30);
81
82         hello.show();
83         return app.exec();
84     }' >main.cpp
85    qmake -project
86    qmake -spec win32-x-g++ -r CONFIG+=release
87    make
88
89## Building Boost on Windows
90
91Download the source from boost.org (tested with 1.50.0), DOS EOL mandatory!
92
93Extract it in a Windows VM
94
95Edit bootstrap.bat to read:
96
97    call .\build.bat mingw %*...
98    set toolset=gcc
99
100And from the MinGW prompt:
101
102    bootstrap
103    b2 toolset=gcc address-model=32 variant=debug,release link=static,shared threading=multi install
104
105 - Copy the whole c:\boost_1_50_0 to the linux machine to ~/qt-x-win32/boost_1_50_0
106
107## (optional) Install NSIS
108
109If _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
111The NSIS compiler should be installed in `~/qt-x-win32/NSIS`.
112
113## Building _glogg_
114
115From this point, building _glogg_ is hopefully straightforward:
116
117    ./release-win32-x.sh
118
119The `release-win32-x.sh` script might need some changes if you use different paths for the dependencies.
120
121The object file is in `./release/`
122