Preface

This document contains instructions on how to build and package ROSA ImageWriter (further referred to as RIW) as portable application.

Generally, the process looks like this:

  1. Compile Qt from sources with static linking.
  2. Build RIW using this Qt version, thus having a single executable binary.
  3. Build the RIW translation files from TS sources.
  4. Put these translations into the lang subdirectory near the RIW executable.
  5. Also copy the same languages from Qt translations into lang.
  6. Add the LICENSE.html and README.html files.
  7. Package the result into appropriate distributable archive.

However, some actions may differ depending on the operating system you are working with. Refer to one of the following sections for details.

Windows

This scenario was tested under Windows 7 SP1 Pro x64, using SDK from Microsoft Visual Studio 2013 Community Edition Update 4.

Configuring and building Qt

Here we suppose that the following paths are used:

From further on we will omit the prefix C:\Programs\Qt-static\.

  1. For static build, special compiler flags are required. Open the file 5.4.1-src\qtbase\mkspecs\win32-msvc2013\qmake.conf and replace the -MD and -MDd flags with -MT and -MTd, respectively (there should be 3 instances). If you are using different version of Visual Studio/SDK, use the file from the correct toolchain subdirectory (e.g. win32-msvc2010 for VS2010).
  2. Open the 32-bit SDK command prompt, change directory to 5.4.1-build\.
  3. Configure the Qt. For decreasing RIW executable size and speed up Qt build process, we recommend to turn off all unused features and modules. The following command can be used:
    ..\5.4.1-src\configure -prefix C:\Programs\Qt-static\5.4.1 -opensource -confirm-license -release -static -target xp -qmake -gui -widgets -accessibility -no-angle -no-audio-backend -no-dbus -no-direct2d -no-directwrite -no-evdev -no-eventfd -no-fontconfig -no-freetype -no-gif -no-harfbuzz -no-iconv -no-icu -no-inotify -largefile -no-libjpeg -qt-libpng -mp -no-mtdev -no-native-gestures -no-nis -no-opengl -no-openssl -no-openvg -qt-pcre -no-plugin-manifests -no-qml-debug -qreal double -rtti -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds -no-ssl -strip -no-style-fusion -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -no-system-proxies -no-use-gold-linker -warnings-are-errors -no-wmf-backend -qt-zlib -nomake examples -nomake tests -skip declarative -skip qtactiveqt -skip qtandroidextras -skip qtconnectivity -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtscript -skip qtscript -skip qtsensors -skip qtserialport -skip qtwebchannel -skip quick1 -skip quickcontrols -skip wayland -skip webkit -skip webkit-examples -skip websockets -skip qtx11extras
  4. When configuring completes, check carefully the status information. Particularly, make sure that correct toolchain is used, otherwise you'll have to specify the toolchain manually (using the QMAKESPEC variable) and reconfigure Qt.
  5. Now run nmake and then nmake install.
  6. Add Qt binaries path to the environment variable PATH:
    set PATH=C:\Programs\Qt-static\5.4.1\bin;%PATH%

Building RIW

Now we can build RIW. It is better to do it in a separate subdirectory to avoid polluting the sources with temporary files.

  1. Create a new directory and go there. Here we suppose that it is subdirectory build\ in RIW sources.
  2. Run the commands:
    qmake ..\RosaImageWriter.pro
    nmake Release
    lrelease ..\RosaImageWriter.pro
  3. If you have digital certificate you can sign the executable file release\RosaImageWriter.exe to allow validation and improve Windows UAC prompt displayed when RIW is started.
  4. All files are now ready, we can package them:
    mkdir pkg\RosaImageWriter\lang
    copy release\RosaImageWriter.exe pkg\RosaImageWriter\
    copy ..\doc\README.html pkg\RosaImageWriter\
    copy ..\doc\LICENSE.html pkg\RosaImageWriter\
    copy ..\lang\*.qm pkg\RosaImageWriter\lang\
    copy C:\Programs\Qt-static\5.4.1\translations\qtbase_ru.qm pkg\RosaImageWriter\lang\
    copy C:\Programs\Qt-static\5.4.1\translations\qtbase_de.qm pkg\RosaImageWriter\lang\
    copy C:\Programs\Qt-static\5.4.1\translations\qt_fr.qm pkg\RosaImageWriter\lang\
    cd pkg
    7z a RosaImageWriter-win.zip RosaImageWriter

    Please, keep in mind that if new RIW translations appear, the commands given above should be amended to also include Qt translations on the same languages. Besides, if Qt translation files become split or combined you should take the appropriate files.
    The last command uses 7-Zip archiver to create ZIP archive; you can use any other tool for that purpose. ZIP format is recommended for distributing the application: though it is not the best one in terms of compression, it's supported by all decompressors and even by Windows itself, so users will have no trouble unpacking it.
  5. The file RosaImageWriter-win.zip is ready for publishing.

Linux

This scenario was tested under ROSA Desktop Fresh R5 i586 and x86_64, using gcc 4.9.2.

Configuring and building Qt

Here we suppose that the following paths are used:

From further on we will omit the prefix ~/Qt-static/.

  1. First, you might want to fix the default build flags. There are two issues in sight: To fix these two issues, open the file 5.4.1-src/qtbase/mkspecs/linux-g++/qmake.conf and add the following directives to the end of the file:
    QMAKE_CFLAGS += -fno-asynchronous-unwind-tables
    QMAKE_CXXFLAGS += -fno-asynchronous-unwind-tables
    QMAKE_LFLAGS += -static-libstdc++
  2. Now, open terminal, change directory to 5.4.1-build/.
  3. Configure the Qt. For decreasing RIW executable size and speed up Qt build process, we recommend to turn off all unused features and modules. The following command can be used:
    ../5.4.1-src/configure -prefix ~/Qt-static/5.4.1 -opensource -confirm-license -release -static -optimized-qmake -gui -widgets -accessibility -no-alsa -no-cups -no-dbus -no-directfb -no-eglfs -no-evdev -fontconfig -qt-freetype -no-gif -no-glib -no-gtkstyle -qt-harfbuzz -no-iconv -no-icu -no-journald -no-kms -largefile -no-libjpeg -qt-libpng -no-linuxfb -no-mtdev -no-nis -no-opengl -no-openssl -no-pch -qt-pcre -no-pkg-config -no-pulseaudio -no-qml-debug -qreal double -reduce-relocations -no-rpath -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds -strip -no-system-proxies -use-gold-linker -no-warnings-are-errors -xcb -qt-xcb -no-xcb-xlib -xinput2 -qt-xkbcommon -qt-zlib -nomake examples -nomake tests -skip declarative -skip qtactiveqt -skip qtandroidextras -skip qtconnectivity -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtscript -skip qtscript -skip qtsensors -skip qtserialport -skip qtwebchannel -skip quick1 -skip quickcontrols -skip wayland -skip webkit -skip webkit-examples -skip websockets -skip qtwinextras -no-libudev
  4. When configuring completes, check carefully the status information. Particularly, make sure that correct toolchain is used, otherwise you'll have to specify the toolchain manually (using the QMAKESPEC variable) and reconfigure Qt.
  5. Now run make and then make install.
  6. Add Qt binaries path to the environment variable PATH:
    export PATH=~/Qt-static/5.4.1/bin:$PATH

Building RIW

Now we can build RIW. It is better to do it in a separate subdirectory to avoid polluting the sources with temporary files.

  1. Create a new directory and go there. Here we suppose that it is subdirectory build/ in RIW sources.
  2. Run the commands:
    qmake ../RosaImageWriter.pro
    make
    lrelease ../RosaImageWriter.pro
  3. All files are now ready, we can package them:
    mkdir -p pkg/RosaImageWriter/lang
    cp RosaImageWriter ../doc/README.html ../doc/LICENSE.html pkg/RosaImageWriter/
    cp ../lang/*.qm ~/Qt-static/5.4.1/translations/{qtbase_ru,qtbase_de,qt_fr}.qm pkg/RosaImageWriter/lang/
    cd pkg
    tar cJf RosaImageWriter-lin.tar.xz RosaImageWriter

    Please, keep in mind that if new RIW translations appear, the commands given above should be amended to also include Qt translations on the same languages. Besides, if Qt translation files become split or combined you should take the appropriate files.
  4. The file RosaImageWriter-lin.tar.xz is ready for publishing.

Mac OS X

This scenario was tested under OS X 10.8.5 Mountain Lion, using Xcode 5.1.1.

Configuring and building Qt

Here we suppose that the following paths are used:

From further on we will omit the prefix ~/Qt-static/.

  1. If you installed Xcode first time you need to start it and accept the license agreement. Otherwise command-line build tools will not work.
  2. Open terminal, change directory to 5.4.1-build/.
  3. Configure the Qt. For decreasing RIW executable size and speed up Qt build process, we recommend to turn off all unused features and modules. The following command can be used:
    ../5.4.1-src/configure -prefix ~/Qt-static/5.4.1 -opensource -confirm-license -release -static -optimized-qmake -gui -widgets -accessibility -no-alsa -no-cups -no-dbus -no-directfb -no-eglfs -no-evdev -no-fontconfig -no-freetype -no-gif -no-glib -no-gtkstyle -qt-harfbuzz -no-iconv -no-icu -no-journald -no-kms -largefile -no-libjpeg -qt-libpng -no-linuxfb -no-mtdev -no-nis -no-opengl -no-openssl -no-pch -qt-pcre -no-pkg-config -no-pulseaudio -no-qml-debug -qreal double -no-reduce-relocations -no-rpath -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds -strip -no-system-proxies -no-use-gold-linker -no-warnings-are-errors -no-xcb -no-xcb-xlib -no-xinput2 -qt-xkbcommon -qt-zlib -nomake examples -nomake tests -skip declarative -skip qtactiveqt -skip qtandroidextras -skip qtconnectivity -skip qtlocation -skip qtmultimedia -skip qtscript -skip qtscript -skip qtsensors -skip qtserialport -skip qtwebchannel -skip quick1 -skip quickcontrols -skip wayland -skip webkit -skip webkit-examples -skip websockets -skip qtwinextras -skip qtx11extras -no-libudev -no-framework
  4. When configuring completes, check carefully the status information.
  5. Now run make and then make install.
  6. Add Qt binaries path to the environment variable PATH:
    export PATH=~/Qt-static/5.4.1/bin:$PATH

Building RIW

Now we can build RIW. Under OS X we have to do it in the sources directory, otherwise the Info.plist for some reason cannot be processed.

  1. Go to the RIW sources directory.
  2. Run the commands:
    qmake RosaImageWriter.pro
    make
    lrelease RosaImageWriter.pro
  3. The application bundle is now ready, we can supply it with additional files and package it:
    mkdir pkg
    mv RosaImageWriter.app pkg/
    mkdir pkg/RosaImageWriter.app/Contents/MacOS/lang
    cp doc/README.html doc/LICENSE.html pkg/
    cp lang/*.qm ~/Qt-static/5.4.1/translations/{qtbase_ru,qtbase_de.pm,qt_fr}.qm pkg/RosaImageWriter.app/Contents/MacOS/lang/
    hdiutil create -format UDBZ -volname 'ROSA ImageWriter' -scrub -srcfolder pkg/ temp.dmg
    hdiutil convert temp.dmg -format UDBZ -o RosaImageWriter-osx.dmg
    rm -f temp.dmg

    (Converting from UDBZ to UDBZ is not required but, though it looks strange, it might decrease the DMG image size by 4%.)
    Please, keep in mind that if new RIW translations appear, the commands given above should be amended to also include Qt translations on the same languages. Besides, if Qt translation files become split or combined you should take the appropriate files.
  4. The file RosaImageWriter-osx.dmg is ready for publishing.

Copyright © 2015 NTC IT ROSA LLC