126ec69f1SNicolas Bonnefon# Building glogg for Windows 226ec69f1SNicolas Bonnefon 326ec69f1SNicolas BonnefonAs often on Windows, building _glogg_ is more complicated than we would like. 426ec69f1SNicolas BonnefonThe method we use to test and generate the builds available on 526ec69f1SNicolas Bonnefonglogg.bonnefon.org is to cross-build _glogg_ from a Debian/Ubuntu machine. 626ec69f1SNicolas Bonnefon 726ec69f1SNicolas BonnefonThe compiler currently used is MinGW-W64 4.6.3, which is available on Debian unstable and Ubuntu 12.04 LTS: 826ec69f1SNicolas Bonnefon 926ec69f1SNicolas Bonnefon apt-get install g++-mingw-w64-i686 1026ec69f1SNicolas Bonnefon 1126ec69f1SNicolas BonnefonThere are two dependencies that must be built for Windows: 1226ec69f1SNicolas Bonnefon - Qt, we currently use version 4.8.2 1326ec69f1SNicolas Bonnefon - Boost, we currently use version 1.50.0 1426ec69f1SNicolas Bonnefon 1526ec69f1SNicolas BonnefonOnce the dependencies are installed (see below), a script takes care of the building and the packaging: 1626ec69f1SNicolas Bonnefon 1726ec69f1SNicolas Bonnefon ./release-win32-x.sh 1826ec69f1SNicolas Bonnefon 1926ec69f1SNicolas Bonnefon## Building Qt on Windows 2026ec69f1SNicolas Bonnefon 2126ec69f1SNicolas BonnefonIt is allegedly possible to cross-compile Qt from Windows but after a lot of 2226ec69f1SNicolas Bonnefonfrustration, the _glogg_ team is building it natively on Windows (using a 2326ec69f1SNicolas BonnefonWindows 7 64bit VM in VirtualBox) and then using the binary generated from the 2426ec69f1SNicolas BonnefonLinux machine. Amazingly, it works as long as we are using a similar version 2526ec69f1SNicolas Bonnefonof gcc (MinGW-W64) on both machines. 2626ec69f1SNicolas Bonnefon 2726ec69f1SNicolas BonnefonHere are instructions to do the build in a Windows 7 VM: 2826ec69f1SNicolas Bonnefon 2926ec69f1SNicolas 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*f05e8befSNicolas Bonnefon - Install the .NET Framework 4 (http://www.microsoft.com/en-us/download/details.aspx?id=17718) 31*f05e8befSNicolas Bonnefon - Install the Windows SDK (http://www.microsoft.com/en-us/download/details.aspx?id=8279) 3226ec69f1SNicolas Bonnefon - Install mingw-w64 from TDM-GCC (tdm64-gcc, tested with 4.6.1). 3326ec69f1SNicolas Bonnefon - Extract the Qt source in c:\qt\4.8.2 3426ec69f1SNicolas Bonnefon 3526ec69f1SNicolas BonnefonIf building a 32 bits version of Qt (what we do for _glogg_): 3626ec69f1SNicolas Bonnefon 37*f05e8befSNicolas Bonnefon - Modify qt/4.8.2/mkspecs/win32-g++/qmake.conf to add `-m32` to `QMAKE_CFLAGS` and `QMAKE_LFLAGS` 3826ec69f1SNicolas Bonnefon - Modify qt/4.8.2/mkspecs/win32-g++/qmake.conf to replace: `QMAKE_RC = windres -F pe-i386` 3926ec69f1SNicolas Bonnefon - (optionally make other changes here to improve performances) 4026ec69f1SNicolas Bonnefon 4126ec69f1SNicolas BonnefonBuild from the MinGW command prompt: 4226ec69f1SNicolas Bonnefon 43*f05e8befSNicolas 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 -qt-style-windowsxp -qt-style-windowsvista 4426ec69f1SNicolas Bonnefon mingw32-make 4526ec69f1SNicolas Bonnefon 4626ec69f1SNicolas Bonnefon - copy the whole `qt/4.8.2` to the linux machine in `~/qt-x-win32/qt_win/4.8.2` 4726ec69f1SNicolas Bonnefon 4826ec69f1SNicolas Bonnefon### Creating the cross-compiled Qt target 4926ec69f1SNicolas Bonnefon 5026ec69f1SNicolas Bonnefon - Install ~/qt-x-win32 created before 5126ec69f1SNicolas Bonnefon 5226ec69f1SNicolas BonnefonThen create a copy of the standard gcc target to create the new cross-gcc target: 5326ec69f1SNicolas Bonnefon 5426ec69f1SNicolas Bonnefon cd /usr/share/qt4/mkspecs/ 5526ec69f1SNicolas Bonnefon sudo cp -a win32-g++ win32-x-g++ 5626ec69f1SNicolas Bonnefon 5726ec69f1SNicolas Bonnefonand modify it to point to the cross-compiler and our local version of Windows Qt: 5826ec69f1SNicolas Bonnefon 5926ec69f1SNicolas Bonnefon sudo sed -i -re 's/ (gcc|g\+\+)/ i686-w64-mingw32-\1/' win32-x-g++/qmake.conf 6026ec69f1SNicolas Bonnefon sudo sed -i -re '/QMAKE_SH/iQMAKE_SH=1' win32-x-g++/qmake.conf 6126ec69f1SNicolas Bonnefon sudo sed -i -re 's/QMAKE_COPY_DIR.*$/QMAKE_COPY_DIR = cp -r/' win32-x-g++/qmake.conf 62*f05e8befSNicolas Bonnefon sudo sed -i -re '/QMAKE_LFLAGS/s/$/ -mwindows -static-libgcc -static-libstdc++/' win32-x-g++/qmake.conf 6326ec69f1SNicolas Bonnefon sudo sed -i -re 's/QMAKE_RC.*$/QMAKE_RC = i686-w64-mingw32-windres/' win32-x-g++/qmake.conf 6426ec69f1SNicolas Bonnefon sudo sed -i -re 's/QMAKE_STRIP\s.*$/QMAKE_STRIP = i686-w64-mingw32-strip/' win32-x-g++/qmake.conf 6526ec69f1SNicolas Bonnefon sudo sed -i -re 's/\.exe//' win32-x-g++/qmake.conf 6626ec69f1SNicolas Bonnefon sudo sed -i -re 's/QMAKE_INCDIR\s.*$/QMAKE_INCDIR = \/usr\/i686-w64-mingw32\/include/' win32-x-g++/qmake.conf 6726ec69f1SNicolas 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 6826ec69f1SNicolas 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 6926ec69f1SNicolas Bonnefon 7026ec69f1SNicolas BonnefonNow you can build a hello world to test Qt: 7126ec69f1SNicolas Bonnefon 7226ec69f1SNicolas Bonnefon mkdir /tmp/testqt 7326ec69f1SNicolas Bonnefon cd /tmp/testqt 7426ec69f1SNicolas Bonnefon echo '#include <QApplication> 7526ec69f1SNicolas Bonnefon #include <QPushButton> 7626ec69f1SNicolas Bonnefon 7726ec69f1SNicolas Bonnefon int main(int argc, char *argv[]) 7826ec69f1SNicolas Bonnefon { 7926ec69f1SNicolas Bonnefon QApplication app(argc, argv); 8026ec69f1SNicolas Bonnefon 8126ec69f1SNicolas Bonnefon QPushButton hello("Hello world!"); 8226ec69f1SNicolas Bonnefon hello.resize(100, 30); 8326ec69f1SNicolas Bonnefon 8426ec69f1SNicolas Bonnefon hello.show(); 8526ec69f1SNicolas Bonnefon return app.exec(); 8626ec69f1SNicolas Bonnefon }' >main.cpp 8726ec69f1SNicolas Bonnefon qmake -project 8826ec69f1SNicolas Bonnefon qmake -spec win32-x-g++ -r CONFIG+=release 8926ec69f1SNicolas Bonnefon make 9026ec69f1SNicolas Bonnefon 9126ec69f1SNicolas Bonnefon## Building Boost on Windows 9226ec69f1SNicolas Bonnefon 9326ec69f1SNicolas BonnefonDownload the source from boost.org (tested with 1.50.0), DOS EOL mandatory! 9426ec69f1SNicolas Bonnefon 9526ec69f1SNicolas BonnefonExtract it in a Windows VM 9626ec69f1SNicolas Bonnefon 9726ec69f1SNicolas BonnefonEdit bootstrap.bat to read: 9826ec69f1SNicolas Bonnefon 9926ec69f1SNicolas Bonnefon call .\build.bat mingw %*... 10026ec69f1SNicolas Bonnefon set toolset=gcc 10126ec69f1SNicolas Bonnefon 10226ec69f1SNicolas BonnefonAnd from the MinGW prompt: 10326ec69f1SNicolas Bonnefon 10426ec69f1SNicolas Bonnefon bootstrap 10526ec69f1SNicolas Bonnefon b2 toolset=gcc address-model=32 variant=debug,release link=static,shared threading=multi install 10626ec69f1SNicolas Bonnefon 10726ec69f1SNicolas Bonnefon - Copy the whole c:\boost_1_50_0 to the linux machine to ~/qt-x-win32/boost_1_50_0 10826ec69f1SNicolas Bonnefon 10926ec69f1SNicolas Bonnefon## (optional) Install NSIS 11026ec69f1SNicolas Bonnefon 11126ec69f1SNicolas 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_. 11226ec69f1SNicolas Bonnefon 11326ec69f1SNicolas BonnefonThe NSIS compiler should be installed in `~/qt-x-win32/NSIS`. 11426ec69f1SNicolas Bonnefon 11526ec69f1SNicolas Bonnefon## Building _glogg_ 11626ec69f1SNicolas Bonnefon 11726ec69f1SNicolas BonnefonFrom this point, building _glogg_ is hopefully straightforward: 11826ec69f1SNicolas Bonnefon 11926ec69f1SNicolas Bonnefon ./release-win32-x.sh 12026ec69f1SNicolas Bonnefon 12126ec69f1SNicolas BonnefonThe `release-win32-x.sh` script might need some changes if you use different paths for the dependencies. 12226ec69f1SNicolas Bonnefon 12326ec69f1SNicolas BonnefonThe object file is in `./release/` 124