Comments, Code and Qt. Some words about the wonderful world of software engineering


How to set up MeeGo Harmattan development environment in Linux

Nokia N9 and MeeGo Harmattan are here. These are good times to be a Qt developer. And if you are like me, you downloaded the Qt SDK 1.1.2 from Nokia that contains the experimental Harmattan target for Qt Creator. However, not sure about you, but I never got the QEMU to work which I though would be a part of the Qt SDK 1.1.2. Whenever I launch a Qt application with the Harmattan as the selected target, I get an error saying that QEMU was not running, so I assume it's not included or Qt Creator cannot find it. Or then I just don't understand how to set it up in Qt Creator... There's even a page at that explains how to use and install the QEMU on a Linux Debian based machine, but the download link to QEMU is broken (25.6.2011). Also it seems that it's a bit open what the deal with QEMU on Windows or OS X based machine are... I haven't seen similar pages for downloading QEMU for other than Linux. So at this point I am not sure if and how the QEMU should work together with Qt Creator. I forgot about the QEMU option then. Update: Ok, I got QEMU running in Linux. It seems there is one step missing in the default Qt SDK 1.1.2 installation. What you need to do is manually select "MeeGo 1.2 Harmattan API" as the Qt version to build with, even if you selected the Harmattan target (there is also a "Harmattan Platform API" Qt version available to use - not sure what that is...). To use QEMU with Qt SDK 1.1.2, go to “Projects > Harmattan > Build > Edit build configuration” and click “Add”. Select “Using Qt Version MeeGo 1.2 Harmattan API (Qt SDK)”. This was in the comments of Qt Labs blog post - I hope Nokia can address this issue soon. I only tested this in Linux. But QEMU is SLOOOOOOW. If you are using Linux, I think you are better off sticking with Scratchbox.

Scratchbox as a Harmattan development environment

Scratchbox is a sandboxed cross-compiling environment that Nokia has been using for Maemo development ever since the first Maemo device, the Nokia 770. It has also been used in Harmattan development so it is no surprise that Nokia also has instructions for setting up Scratchbox for Harmattan development. But this seems like a totally different developer story from the Qt SDK one. I also don't see how Scratchbox is going to work on anything else but Linux based machines (and preferably Debian based ones). I hope someone from Nokia could clarify this a bit. In any case, it is not a problem to get started with Scratchbox that includes all the necessary developer packages for Harmattan. Nokia has made a great small Python based utility that will install the complete Harmattan environment for you (how I wish we had this when I worked with Harmattan... ;)). The instructions are on - links below:
  1. Install and setup Scratchbox.
  2. How to use Scratchbox and launch the Harmattan UI. NOTE: The installer will add your user to the group sbox and you need to logout and login once before you can start using Scratchbox.
After step 2. you are ready to start developing your application. If you launch your application inside Scratchbox, it is just like it would be started on the target device. The environment is actually pretty good.
Harmattan Scratchbox environment

Harmattan UI in Xephyr and Scratchbox environment

Developing Harmattan apps with the Scratchbox environment

Getting started with Scratchbox can take some time and it's definitely not the integrated development experience Qt SDK tries to provide. So no surprise that I don't like Scratchbox as a development environment, and it is not even meant to be one necessarily. After all it's a cross compilation environment. But you can quite easily install Qt Creator inside Scratchbox if you like and debug your application as it is running inside the Scratchbox environment (remember, Scratchbox is just a sandboxed Debian). Instead, I would do the development outside Scratchbox in my Qt Creator and then I would test the application in Harmattan UI, cross compile the source and build ARM-packages inside Scratchbox. To do this, you need to have a folder and its content visible both inside and outside Scratchbox (and open and edit the files outside Scratchbox in your Qt Creator). This can be easily done with mount --bind. This is how I created a folder ~/src/harmattan outside Scratchbox, that will contain my Harmattan source code, and the same folder and content will be visible as a folder ~/src inside my Scratchbox. kypeli@Cute:~/src$ mkdir harmattan kypeli@Cute:~/src$ mkdir /scratchbox/users/kypeli/home/kypeli/src kypeli@Cute:~/src$ sudo mount --bind harmattan /scratchbox/users/kypeli/home/kypeli/src kypeli@Cute:~/src/harmattan$ echo "Foobar" > foo [sbox-HARMATTAN_X86: ~/src] > cat foo Foobar [sbox-HARMATTAN_X86: ~/src] > Now you can work easily on the same piece of code both inside and outside the chrooted Scratchbox environment. To have this binding in place also after reboots, put this line in your /etc/fstab (with your folders :)): /home/kypeli/src/harmattan /scratchbox/users/kypeli/home/kypeli/src none rw,bind 0 0

Technorati Tags: , , , ,

  • Adam

    Why would you go through the trouble? It’s a dying platform going nowhere which has been orphaned at birth. No thanks.

    • mh

      Adam, youre soo wrong. Dont trust Mr Elop on this… Take a look at the media and testers they like the device.  This device will sell very well. There is some countrys WP7 phones will not even start sell the this year.

      MrElop is just playing a game. Elop current strategy may fail and he will get fired. So ofcourse he has to convince peple its a deadend but it is not!!!

  • Endrixxxx

    Good work! Don’t let hope vanish in the endless confusion of the mindless Elop. Meego might survive him… We just need to sell more than 125,000 N9 and he will get fired. Or at least that is a way to make the board reconsider Strategy. For this please support the community and devolp good apps

    • Adam

      Get him fired after selling 125,000? What a pointless exercise. 125,000 sold units is laughable anyways don’t you see?

      • Endrixxxx

        Dude RTFM!
        Nokia will be able to sell ONLY 125,000 wp phones because that is how many pieces will be assebled this year.
        Elop in the moment a finnish based product outsell the wp shit will not be only facing shareholders and board memeber, but the finnish govt itself. I do not where are you from but I tell you that in Finland Nokia is a big issue

        • One question – what mental hospital is working with your issue? They desperately need to get you more medication LOL

  • First off I have to say that I wrote this piece of text because I love developing with Qt and there will anyway be a community around the device. If there’s economic success around this device or not, that’s a different matter.

    That said, we can speculate as much as we like about the strategy around the N9. All the numbers that are thrown around are anyway more or less guesses. We don’t know if Nokia is going to distribute this to the US via some carrier or not for example. There are many people out there who like devices even if they don’t have 100.000 apps available (which, anyway, most of are crap). Nokia will support this device with software updates, what else do we expect? It will have a normal warranty plan like any other phone. Honesty, if you like this device, I don’t see the point in saying that it will be Nokia’s only MeeGo handset. So what? I am sure there are other MeeGo handsets to come, but that’s also besides the point: if you like this device or if you like developing for Qt, it does not matter if Nokia next year sells only WP based phones.

  • Shouldn’t it be possible to configure Qt Creator to deploy into Scratchbox and run in Scratchbox into Xephyr? The “deploy” and “build” steps are customisable, so I *think* this should be doable.

    Did you install Harmattan alongside existing Fremantle targets? I don’t want two Scratchbox installs…

    • Sounds very plausible – I am sure it’s possible to configure Qt Creator to build and deploy inside SB too. Could be worth the effort.

      I didn’t have a Fremantle installation on this machine, so I only have one SB with this Harmattan target in it. Not sure if it’s even possible to have two distinct SB installations with one target each 🙂 You can, of course, have more targets inside a SB – one for Fremantle and one for Harmattan. But then you can’t use the nice installation script.

      • Apparently it “just works” (in terms of installing and updating alongside the Fremantle targets) – we’ll see.

        Once up and running I’ll look at getting Qt Creator to use Scratchbox as a compiler/runner. Hell, it should even be possible to do it for Fremantle as well (although I have a Fremantle device so it’s less of a problem ;-))

  • Regarding the errors in deploying to the device, where it instead invokes Qemu. My notes on the subject:

    -> turns out the important missing step in the above instructions is in “Harmattan->Run” not “Harmattan->Build”
    -> there, under Deployment there’s a option menu w/choices “Qemu (default)” or “Deploy to Harmattan Device” select the latter and you’re good.
    -> The problem is caused by “Qemu (default)” it shouldn’t be the default. In Tools->Options->Maemo->Maemo Device Configuration after setting up the N950 device, need to also click “Set as Default” — then the device will automatically be selected in step above and problem would have been avoided.

  • Also, using the suggestion I gave above. it turns out that
    “Qt Version MeeGo 1.2 Harmattan API (Qt SDK)” is not relevant to solving the problem, but setting the “Run” setting to the harmattan device and not qemu is what makes it work.

    I just compiled and ran using that technique and it was set to “Harmattan Platform API” not “MeeGo 1.2 Harmattan”….

    By the way, doesn’t selecting “Harmattan Platform API” give you Qt 4.7.4 whereas MeeGo 1.2 is stuck at 4.7.2 ?
    4.7.4 is installed on Harmattan:

    p, li { white-space: pre-wrap; }

    libqt4 4.7.4~git20110516-0maemo1+0m6

    libqt4-core 4.7.4~git20110516-0maemo1+0m6

    libqt4-dbus 4.7.4~git20110516-0maemo1+0m6

    libqt4-declarative 4.7.4~git20110516-0maemo1+0m6

    libqt4-gui 4.7.4~git20110516-0maemo1+0m6

    libqt4-meego 4.7.4~git20110516-0maemo1+0m6

    libqt4-meegographicssystem 4.7.4~git20110516-0maemo1+0m6

    libqt4-meegographicssystemhelper 4.7.4~git20110516-0maemo1+0m6

    libqt4-network 4.7.4~git20110516-0maemo1+0m6

    libqt4-opengl 4.7.4~git20110516-0maemo1+0m6

    libqt4-phonon 4.7.4~git20110516-0maemo1+0m6

    libqt4-script 4.7.4~git20110516-0maemo1+0m6

    libqt4-sql 4.7.4~git20110516-0maemo1+0m6

    libqt4-sql-sqlite 4.7.4~git20110516-0maemo1+0m6

    libqt4-svg 4.7.4~git20110516-0maemo1+0m6

    libqt4-test 4.7.4~git20110516-0maemo1+0m6

    libqt4-xml 4.7.4~git20110516-0maemo1+0m6

    libqt4-xmlpatterns 4.7.4~git20110516-0maemo1+0m6