jump to navigation

Running Qt for S60 SDK on Linux July 29, 2009

Posted by lizardo in General.
Tags: , , ,
comments closed

Update (2009-08-04): fixed qt_s60_gnupoc.patch (thanks grego), plus a few text additions.
Update (2009-08-21): update instructions to support S60 5.0 too.

A while ago I started playing with S60 programming. After downloading rather big SDK files and following instructions from http://www.martin.st/symbian/, I was able to build simple “hello world” applications written in C++, on Linux.

Then I remembered reading about an experimental Qt port to S60. I wanted to try it, given that I also began playing with Qt a while ago. To my surprise, I could not find any actual instructions on how to do that on Linux, although I found a few requests for it in comments from Qt Labs blog posts.

So, without further delay, I describe below the steps I followed to build Qt applications for S60 devices on Linux. These instructions are provided as an extension to those on Martin’s page, so be sure to read it too. But given that some patches are needed on top of Martin’s tools, I will show the full instructions here.

Note: these instructions were tested only in the following environment:

  • x86 32-bits
  • Ubuntu 8.04
  • S60 3.1 (N95) and S60 5.0 (5800 Xpress Music)

I tried making it work for my 3.0 MR based device, but it seems that I need to recompile all Qt using the proprietary ARM RVCT compiler. If someday I make it work, I’ll post instructions for it too.

Preparation

Download all required files:

(many thanks to Francisco Keppler for hosting the last two files on his web site!)

Installation

  1. First, set some environment variables to be used on the following steps (feel free to modify them to install the SDK on some other location). NOTE: these variables are not necessary after installation.
  2. # root directory where all SDK files will be installed
    GNUPOC_ROOT=$HOME/gnupoc
     
    # toolchain directory
    TOOLCHAIN_DIR=$GNUPOC_ROOT/csl_gcc
     
    # S60 SDK directory (replace "3.1" with "5.0"
    # for S60 5.0)
    S60_SDK_DIR=$GNUPOC_ROOT/symbian-sdks/3.1
     
    # Qt SDK directory
    QT_S60_DIR=$GNUPOC_ROOT/qt_s60
     
    # wrapper directory (used by gnupoc)
    WRAPPER_DIR=$GNUPOC_ROOT/bin
     
    # where all downloaded files are located
    SRC_DIR=$HOME/downloads

  3. Install ARM toolchain:
  4. mkdir -p $TOOLCHAIN_DIR
    tar -C $TOOLCHAIN_DIR -xvjf \
      $SRC_DIR/gnu-csl-arm-2005Q1C-arm-none-symbianelf-i686-pc-linux-gnu.tar.bz2

  5. Unpack gnupoc sources and apply the patch that adds Qt/S60 support:
  6. tar -xvzf $SRC_DIR/gnupoc-package-1.13.tar.gz
    cd gnupoc-package-1.13
    patch -p1 -i $SRC_DIR/qt_s60_gnupoc.patch

  7. Install gnupoc:
    • For S60 3.1:
    • cd sdks
      ./install_gnupoc_s60_31 \
        $SRC_DIR/S60-SDK-200634-3.1-Cpp-f.1090b.zip \
        $S60_SDK_DIR

    • For S60 5.0:
    • cd sdks
      ./install_gnupoc_s60_50 \
        $SRC_DIR/S60_5th_Edition_SDK_v1_0_en.zip \
        $S60_SDK_DIR

  8. Install gnupoc wrappers and native tools:
  9. ./install_wrapper $WRAPPER_DIR
    cd ../tools
    ./install_eka2_tools $TOOLCHAIN_DIR
    # adjust EKA2TOOLS variable to point to correct location
    sed -i "s,EKA2TOOLS=.*,EKA2TOOLS=$TOOLCHAIN_DIR/bin," \
      $WRAPPER_DIR/gnupoc-common.sh

  10. Install OpenC (skip this step if using S60 5.0):
  11. cd ../sdks
    chmod +x install_openc.sh
    ./install_openc.sh \
      $SRC_DIR/OpenC-1.5.5b-beta.zip \
      $S60_SDK_DIR

  12. Finally, install Qt/S60 (it will take some time because some tools need to be compiled for Linux):
  13. chmod +x install_qt_s60.sh
    ./install_qt_s60.sh \
      $SRC_DIR/qt-embedded-s60-preview-4.5.2-tower.exe \
      $S60_SDK_DIR \
      $QT_S60_DIR \
      $SRC_DIR/qt-s60-extra-files.tar.gz

Usage

After installation is completed, the usage is very simple. You need to setup a few environment variables, so tools like qmake, bldmake, abld, makesis etc. are found:

export PATH=$WRAPPER_DIR:$QT_S60_DIR/bin:$PATH
export EPOCROOT=$S60_SDK_DIR/ # trailing "/" is required!
export QMAKESPEC=$QT_S60_DIR/mkspecs/symbian-abld

Optionally, you can create a gnupoc_env.sh file with the lines above, using this command:

cat > $GNUPOC_ROOT/gnupoc_env.sh << EOF
export PATH=$WRAPPER_DIR:$QT_S60_DIR/bin:\$PATH
export EPOCROOT=$S60_SDK_DIR/ # trailing "/" is required!
export QMAKESPEC=$QT_S60_DIR/mkspecs/symbian-abld
EOF

Then, every time you need to set the variables, you could simply use:

. $GNUPOC_ROOT/gnupoc_env.sh

Note the “.” (dot) before the gnupoc_env.sh. It says that the contents of the gnupoc_env.sh file will be run in the current shell session, as if you typed them by hand.

To actually build some Qt code, use these commands:

cd path/to/source
qmake # assuming the code already has a .pro file
make DEL_FILE=rm ABLD=abld release-gcce
makesis -c <project>_gcce_urel.pkg <project>.sis

And to clean the source:

make DEL_FILE=rm ABLD=abld distclean

Notes:

  • Be sure to use qmake from Qt/S60. Otherwise the generated Makefiles will be for your host system
  • The trailing slash on the EPOCROOT variable is important

Known issue and workaround

The .sis file generated by the instructions above, although installable on the device, does not actually work (clicking on the application icon makes the phone “hang” for a while, but then it returns to the Symbian menu). The workaround is to compile and link some files from Qt/S60 sources directly into the application. For that, just add a “qts60main.pri” file to your application’s source directory, with the following content:

QT_SOURCE_TREE = $$QMAKE_INCDIR_QT/..
DEPENDPATH += $$QT_SOURCE_TREE/src/s60main
 
HEADERS += \
qts60mainapplication.h \
qts60mainappui.h \
qts60maindocument.h
 
SOURCES += \
qts60mainapplication.cpp \
qts60mainappui.cpp \
qts60main.cpp \
qts60maindocument.cpp \
qts60main_mcrt0.cpp
 
LIBS -= qtmain
QMAKE_LIBS -= qtmain
 
MMP_RULES += \
"SOURCEPATH $$QT_SOURCE_TREE/src/s60main" \
"START RESOURCE s60main.rss" \
"HEADER" \
"TARGETPATH /resource/apps" \
"END"

Edit the .pro file and add this line:

include(qts60main.pri)

Then try again the sequence of commands listed on the previous section (qmake; bldmake …). I’m not sure why this happens, and I need to check whether this is an issue specific to Linux.

TODO

  • Remove need to set “DEL_FILE=rm ABLD=abld” when calling make distclean/relase-*
  • Send patches to Martin’s gnupoc and Qt/S60
  • Investigate issue with s60main static library not working
  • Compile Qt/S60 from sources on Linux
  • Make it work with S60 3.0 too (although Qt/S60 does not support it officially)
  • Make Symbian emulator (epoc.exe) work under Linux (currently it crashes under WINE)