Saturday, 11 May 2013

Setting up the SailfishOS Toolkit for both SailfishOs and Harmattan:


Note: This post will be updated for the Qt5 Alpha shortly!

In this post I show how to setup QtCreator from the SailfishOS Toolkit so that we can develop both for Harmattan and for SailfishOS from one IDE.

Why would you want to do this?

If like me you want to port your Harmattan apps to SailfishOS, and wish to keep both versions running from a common project with a common code base, then it is very handy to be able to build run and launch our apps from one IDE in both Emulators side by side.

As a first baby-step in a migration it would be wise to get our existing apps running on the Nokia Simulator, Harmattan QEMU Emulator, and the physical device (e.g. Nokia N9) from the SailfishOS Toolkit before we even think of touching the code to port anything. This follows the basic software engineering principle of only changing one thing at at time.

Once this works, then our next challenge will be to get the same projects running on SailfishOS, and to migrate from Harmattan to Silica components…

Some Nomenclature:

In the context of this post I will use "Toolkit" to refer to the entire development suite including the IDE, Toolchain, VMs, Simulators and Emulators etc. Often SDK would be used for this, but in the Sailfish world the term SDK often refers to one element of the toolkit, namely the MERSDK virtual machine.

Differences between the Toolkits: 

While the Nokia and SailfishOS Toolkits have much in common, there are several key differences between the two:

a) QtCreator Version: 
Nokia delivers 2.4.1,
Sailfish alpha 2.6.2.

b) Qt Version:
Nokia supports Qt 4.7.4,
Sailfish alpha Qt 4.8.3

c) Approach to building: 
The Nokia Toolkit used the host system to cross-compile to the Emulator, which meant the compiler differs from host to host. 

The SailfishOS Toolkit delivers an additional tool, namely the MERDSK Virtual machine which hosts the build chain. i.e the same compiler is used regardless of the operating system of your host system.

d) Simulators and Emulators
The Nokia Toolkit delivered both a Simulator and an Emulator. The simulator was actually closer to the host than the N9, but allowed simulating of sensor inputs (e.g GPS signal, SMS etc.). The Emulator was much closer to the end device, and was based on a QEMU virtual machine.

The SailfishOS forgoes the simulator. It delivers "only* an Emulator, running in a VirtualBox virtual machine. This should not be confused with the MERSDK mentioned above which also runs in an VirtualBox virtual machine.

My Host Platform:

My primary development host is  currently OSX (but I am NOT at Machead), so I will use that as a reference in the instruction below: but things will be broadly similar for Windows and Linux users. As I also have Win7 and Lubuntu Installations of the Sailfish Toolkit maybe I will add Win7 and Linux tips to this post at a later date.


Even though we will be working only from the QtCreator that the SailfishOS Toolkit delivers, we will need to have both Toolkits installed: We will set up the Sailfish QtCreator to use the Simulator and Emulator from the Harmattan Toolkit.

a) You have already installed the Nokia Qt SDK 1.2.1 and used it to develop Harmattan apps. The SDK is available here

b) You have downloaded and installed the SailfishOS Toolkit available here:

Setting up SailfishOS Toolkit for Harmattan

We will configure devices, compilers, Qt Versions, and kits. for the Nokia Harmattan Simulator, QEMU, and N9

Step 1: Add Devices:

The first step is to add devices to QtCreator: Out-of-the-box you should already have the SailfishOS Emulator: We will add the Meego / Harmattan QEMU, and the N9.

In QtCreator / Preferences / Devices; Windows: Tools / Options / Devices

a) Add QEMU

b) Add N9

Step 2: Add Compilers:

Preferences / Build & Run / Compilers

a) add GCC Harmattan

Compiler Path = /Users/<yourhomedrive>/QtSDK/Madde/targets/harmattan_10.2011.34-1_rt1.2/bin/gcc

Step 3: Add Qt Versions:

Preferences / Build & Run / Qt Versions

SailfishOS currently is based on Qt 4.8.3 which will be auto-detected, but Harmattan uses Qt 4.7.4, so we need to add 4.7.4 for the Simulator, and for the QEMU / N9.

a) 4.7.4 for the Simulator

qmake location = /Users/<yourhomedrive>/QtSDK/Simulator/Qt/gcc/bin/qmake

b) 4.7.4 for QEMU and the N9

qmake location = /Users/<yourhomedrive>/ QtSDK/Madde/targets/harmattan_10.2011.34-1_rt1.2/bin/qmake

Step 4: Add Kits:

Preferences / Build & Run / Kits

a) MerkSDK-SailfishOS-i486-x86
Should be Auto-detected

b) Add Qt Simulator N9


c) Add QEMU Qt 4.7.4 (harmattan_10.2011.34-1_rt1.29


d) Add N9 Qt 4.7.4 (harmattan_10.2011.34-1_rt1.2)
Sysroot: = /Users/<yourhomedrive>/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim

Step 5: First Tests:

Test an existing Harmattan app, you should now be able to build and run against:
a) the Nokia / Qt Simulator
b) the QEMU Emulator
c) the N9 itself

.. and then, Fingers in Ears Time: First Run on SailfishOS!

The SailfishOS: Is unlikely to run first time - but give it a go anyway.

You will probably need additional packages added to the MERSDK and SailfishOS Emulator to run your Harmattan apps unchanged. More on that in a later post….

No comments:

Post a Comment