jump to navigation

Installing Qt for Symbian on Linux September 24, 2009

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

*** These instructions have been superseded by the GnuPoc and Qt for Symbian unofficial installers, described in this post***

 

Update (2009-09-24): Add workaround for GCCE issue.
Update (2009-10-05): Update gnupoc patch to apply against 20091005 snapshot. Remove workarounds from “Known Issues” sections that are already integrated into new patch.
Update (2009-10-07): Add instruction for installing gnupoc build dependencies.
Update (2009-10-23): New patch version (v9), that now applies cleanly to latest snapshots.
Update (2009-11-17): New patch version (v10), now applies against the 4.6.0 RC1 release.

In a previous post, I provided instructions on running Qt for Symbian (the “Tower” release) on Linux. However, for those who want to play with the bleeding edge Qt for Symbian development, you might want to try out the latest 4.6 development code from Qt GIT. I put some instructions for compiling Qt for Symbian from GIT on Linux as well, but unfortunately it requires the RVCT compiler to build.

Fortunately, today espenr announced daily snapshots, that will allow those who don’t have access to RVCT to try out the latest 4.6 development as well :D . So how to get this thing running on Linux? The snapshots so far consist only of the Windows installer and a .zip containing the source code.

By “merging” information from my two previous posts, I will describe below how to install the Qt for Symbian daily snapshots on Linux. Even if you have a previous installation of the Symbian SDK, you will need to follow the full instructions again (sorry), as these instructions contain a bunch of bug fixes to the Symbian SDK. Hopefully this requirement will go away at some point, when all Symbian SDK portability issues are addressed.

These instructions also work for the just released 4.6.0 RC1.

These instructions were tested only in the following environment:

  • Host: x86 32-bits (running Ubuntu 8.10)
  • Device and SDK: S60 5.0 (N97 and 5800)

Preparation

Download all required files:

(many thanks to Francisco Keppler for hosting this last file on his web site!)

For building the native tools from gnupoc, you will need:

  • the GCC C/C++ compilers
  • development files for zlib
  • development files for openssl

On Ubuntu, you can install these using the following command:

sudo apt-get install build-essential zlib1g-dev libssl-dev

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
     
    # Symbian SDK directory
    S60_SDK_DIR=$GNUPOC_ROOT/symbian-sdks/5.0
     
    # 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 for Symbian 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_v10.patch

  7. Install Symbian SDK:
  8. cd sdks
    ./install_gnupoc_s60_50 \
      $SRC_DIR/S60_5th_Edition_SDK_v1_0_en.zip \
      $S60_SDK_DIR

  9. Install gnupoc wrappers and native tools:
  10. ./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

  11. Create a “gnupoc_env.sh” script to be used for gnupoc environment setup, by running this command:
  12. cat > $GNUPOC_ROOT/gnupoc_env.sh << EOF
    export PATH=$WRAPPER_DIR:\$PATH
    export EPOCROOT=$S60_SDK_DIR/ # trailing "/" is required!
    EOF

    (Note: the “cat << EOF … EOF” snippet above will generate a “gnupoc_env.sh” file in $GNUPOC_ROOT.)

  13. Initialize the Symbian SDK environment (you will need to do this every time you close the current shell session):
  14. . $GNUPOC_ROOT/gnupoc_env.sh

  15. Install OpenC:
  16. cd ../sdks
    chmod +x install_openc_16_s60
    ./install_openc_16_s60 \
      $SRC_DIR/s60_open_c_cpp_plug_in_v1_6_en.zip \
      $S60_SDK_DIR

  17. Install Qt for Symbian (it will take some time because some tools need to be compiled for Linux):
  18. chmod +x install_qt_s60
    ./install_qt_s60 \
      $SRC_DIR/qt-symbian-opensource-<version>.exe \
      $S60_SDK_DIR \
      $QT_S60_DIR

    If installation went well, you should see the following:
    ...
    Qt is now configured for building. To start the build run:make debug-winscw|debug-armv5|release-armv5.
    To reconfigure, run 'make confclean' and configure.

    Of course, you do not want to build Qt, so just ignore it and proceed with the next step.

  19. Create a “qt_s60_env.sh” script to be used to setup Qt for Symbian environment, by running this command:
  20. cat > $GNUPOC_ROOT/qt_s60_env.sh << EOF
    export PATH=$QT_S60_DIR/bin:\$PATH
    export QMAKESPEC=symbian-abld
    EOF

    (Note: the “cat << EOF … EOF” snippet above will generate a “qt_s60_env.sh” file in $GNUPOC_ROOT.)

  21. Initialize the Qt for Symbian environment (you will need to do this every time you close the current shell session):
  22. . $GNUPOC_ROOT/qt_s60_env.sh

  23. Install the following SIS files on your device:
    • $EPOCROOT/nokia_plugin/openc/s60opencsis/pips_s60_1_6_ss.sis
    • $EPOCROOT/nokia_plugin/openc/s60opencsis/openc_ssl_s60_1_6_ss.sis
    • $EPOCROOT/nokia_plugin/opencpp/s60opencppsis/stdcpp_s60_1_6_ss.sis
    • $QT_S60_DIR/qt_selfsigned.sis
  24. Unset all temporary variables we used earlier:
  25. unset GNUPOC_ROOT TOOLCHAIN_DIR S60_SDK_DIR \
      QT_S60_DIR WRAPPER_DIR SRC_DIR

Usage

You need to setup the environment, so tools like qmake, bldmake, abld, makesis etc. are found (not necessary if you just did the installation, unless you closed the shell session):

. /path/to/gnupoc_env.sh
. /path/to/qt_s60_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 debug-gcce # or make debug-armv5 (if using RVCT)
make sis # to generate .sis file

And to clean the source:

make distclean

Notes:

  • Be sure to use qmake from Qt for Symbian. Otherwise the generated Makefiles will be for your host system
  • The trailing slash on the EPOCROOT variable is important (this is assumed in many places on Symbian SDK scripts)

Known Issues

  • The snapshots contain only the the “debug” libraries. Therefore, only the debug targets will work, i.e. use only “make debug-gcce” (if using GCCE compiler) or “make debug-armv5″ (if using RVCT)

See also the more general known issues related to Qt for Symbian.

Ideas for improvements and TODO items

  • Add Symbian support to Qt configure script, eliminating the need to compile configure.bin
  • Create a nice GUI installer for Linux
  • Allow to easily upgrade Qt for Symbian SDK installation, without requiring to reinstall the entire Symbian SDK
  • Itegration with Qt Creator, KDevelop or some other IDE

Feel free to contribute with your ideas or even better, help implementing them :D

Compiling Qt for S60 (from GIT) on Linux September 5, 2009

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

Update (2009-09-06): Add instructions for generating the .sis file
Update (2009-09-16): Rebase GIT clone against 4.6 branch; update gnupoc patch (V3); add instructions for patch_capabilities.pl
Update (2009-09-17): A few textual fixes; fixes added to the GIT tree; new gnupoc patch (V4); added instructions for testing the built Qt
Update (2009-09-18): fix GIT instructions
Update (2009-09-21): Use RVCT 2.2 (build 686); small changes to the hello example

Currently it is only possible to build Qt for S60 on Windows and using the proprietary RVCT compiler from ARM.

Windows is needed because the Symbian support code contains calls to the Win32 API, Windows style paths (using backslashes), a few calls to .bat and .exe tools, and inconsistent case for path names (a real issue for Unix based systems).

RVCT is needed due to limitations in GCCE (the GCC Symbian port). From the Qt/S60 README:

The current version of GCCE cannot compile the Qt libraries themselves as it has issues with global static data in DLLs. [...]. For more information on this issue see: http://www3.symbian.com/faq.nsf/0/B8542F039C193CCC802573DA0011DFA7

Thanks to the community effort around the gnupoc project (and further modifications made by Martin Storsjö for supporting the newer S60 SDK releases) we are able to build regular S60 applications on Linux. To allow also building Qt applications for S60, it was necessary to port the Symbian support from Qt sources to Linux, and a few more changes to the Symbian SDK scripts to improve Linux support.

You will find below instructions for building Qt for S60 on Linux, using sources from GIT, plus the Linux host support from my own clone.

The RVCT requirement is still necessary, but fortunately there is a Linux version of RVCT available on ARM site (it is paid, but there is a 30-day evaluation version).

Preparation

Although I had previously blogged about installing the S60 SDK on Linux together with the Qt 4.5.2 “tower” release, I will again describe the installation instructions here. Even if you have the S60 SDK already installed, you will need to install it again. This is necessary because gnupoc needs more fixes for building Qt.

That said, download the necessary files:

For building the native tools from gnupoc, you will need:

  • the GCC C/C++ compilers
  • development files for zlib
  • development files for openssl

On Ubuntu, you can install these using the following command:
sudo apt-get install build-essential zlib1g-dev libssl-dev

For building Qt itself, you will also need:

  • RVCT 2.2 (build 686) for Linux installed and accessible on PATH. Run armcc --vsn and you should see:
  • ARM/Thumb C/C++ Compiler, RVCT2.2 [Build 686]

  • WINE. A few tools from S60 SDK (elftran, genstubs and getexports) are only available for Windows. Fortunately, recent versions of WINE are able to run these tools just fine.
  • A copy of Qt GIT tree containing support for Linux host from my tree clone. If you do not have Qt GIT tree downloaded, you get it by running:
  • git clone git://gitorious.org/qt/qt.git
    Next, add a remote for my clone and create a local “s60_linux” branch that will be used to track changes for Linux host support:
    git remote add -f -t s60_linux \
      qt_s60_linux git://gitorious.org/~lizardo/qt/lizardos-qts60.git
    git checkout -b s60_linux qt_s60_linux/s60_linux

    If at some point you need to update the tree (and don’t have any local changes), you can run:
    git checkout s60_linux
    git fetch qt_s60_linux
    git reset --hard qt_s60_linux/s60_linux

S60 SDK Installation (5.0 only)

  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
    S60_SDK_DIR=$GNUPOC_ROOT/symbian-sdks/5.0
     
    # 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 for 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_v4.patch

  7. Install gnupoc:
  8. cd sdks
    ./install_gnupoc_s60_50 \
      $SRC_DIR/S60_5th_Edition_SDK_v1_0_en.zip \
      $S60_SDK_DIR

  9. Install gnupoc wrappers and native tools:
  10. ./install_wrapper $WRAPPER_DIR
    cd ../tools
    ./install_eka2_tools $TOOLCHAIN_DIR
    sed -i "s,EKA2TOOLS=.*,EKA2TOOLS=$TOOLCHAIN_DIR/bin," \
      $WRAPPER_DIR/gnupoc-common.sh

  11. Install OpenC (now necessary even for 5.0 SDK):
  12. cd ../sdks
    chmod +x install_openc_16_s60
    ./install_openc_16_s60 \
      $SRC_DIR/s60_open_c_cpp_plug_in_v1_6_en.zip \
      $S60_SDK_DIR

  13. Add support for RVCT to the SDK:
  14. chmod +x install_rvct_support
    ./install_rvct_support $S60_SDK_DIR

  15. Create a “gnupoc_env.sh” script to be used for gnupoc environment setup, by running this command:
  16. cd $GNUPOC_ROOT
    cat > gnupoc_env.sh << EOF
    export PATH=$WRAPPER_DIR:\$PATH
    export EPOCROOT=$S60_SDK_DIR/ # trailing "/" is required!
    EOF

    (Note: the “cat << EOF … EOF” snippet above will generate a “gnupoc_env.sh” file in $GNUPOC_ROOT.)

  17. Unset all temporary variables we used earlier:
  18. unset TOOLCHAIN_DIR S60_SDK_DIR WRAPPER_DIR SRC_DIR
    (Note: GNUPOC_ROOT is not unset because it will be used later on when creating the environment script for Qt.)

  19. Finally, initialize environment by running:
  20. . gnupoc_env.sh
    (Note the “.” (dot) before gnupoc_env.sh. This command will run the commands listed in gnupoc_env.sh on the current shell session, as if you typed them by hand.)

Building Qt for S60

The current configure shell script used for Linux builds does not contain a full support for Symbian. Therefore the configure.exe source was ported to Linux. Here it is called “configure.bin”, and is generated by the autogen.sh script.

  1. Compile configure.bin:
  2. ./autogen.sh

  3. Configure Qt sources:
  4. ./configure.bin \
      -opensource \
      -confirm-license \
      -platform linux-g++ \
      -xplatform symbian-abld \
      -no-webkit \
      -no-phonon

  5. Compile Qt:
  6. make release-armv5

  7. Create a “qt_s60_env.sh” script to be used for Qt/S60 environment setup, by running this command:
  8. cat > $GNUPOC_ROOT/qt_s60_env.sh << EOF
    export PATH=$PWD/bin:\$PATH
    export QMAKESPEC=symbian-abld
    EOF

    (Note: the “cat << EOF … EOF” snippet above will generate a “qt_s60_env.sh” file in $GNUPOC_ROOT.)

  9. Finally, initialize environment by running:
  10. . $GNUPOC_ROOT/qt_s60_env.sh
    (Note the “.” (dot) before qt_s60_env.sh. This command will run the commands listed in qt_s60_env.sh on the current shell session, as if you typed them by hand.)

Reducing Symbian capabilities for Qt

By default, Qt for S60 requires high Symbian capabilities. It does not use all those capabilities itself, but this is done so that the generated SIS does not limit capabilities for Qt applications that need them. Unless you have access to certificates that can sign with high capabilities, you will need to “patch” the generated binaries so that it only requests the set of capabilities accessible through Open Signed Online or by using self-signed certificates.

Fortunately, there is a script under Qt sources called “patch_capabilities.pl” that does just that. I also modified it so that it “patches” the Secure ID and UID3 to match the range used for development purposes (see this page for more details about Symbian UIDs). To be able to self-sign the generated .sis for Qt, run this command:

perl ./bin/patch_capabilities.pl \
  src/s60installs/Qt_for_S60_template.pkg \
  release-armv5

Note this must be done AFTER building Qt, because it modifies some files generated by the build.

Creating the SIS file

To create the final .sis file for Qt, run this command:

make -C src/s60installs/ sis

You should see output similar to:

Processing qt_for_s60_release-armv5.pkg...
Created qt_for_s60_release-armv5_unsigned.sis
 
Successfully created qt_for_s60_release-armv5.sis using certificate Self Signed!

You will find the generated qt_for_s60_release-armv5.sis under “src/s60installs/”.

Testing the built Qt: hello world!

The Qt source has many examples and demos, but a simple “hello world” is very suitable for checking whether Qt was built correctly and if the environment is properly setup.

First, set the environment for gnupoc and Qt/S60, unless you already run these commands on the current terminal session:

. $GNUPOC_ROOT/gnupoc_env.sh
. $GNUPOC_ROOT/qt_s60_env.sh

Next, create a directory that will contain the hello project:

mkdir hello
cd hello

Now create a “main.cpp” file with the following code:

#include <QtGui>
 
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QPushButton hello("Hello, World!");
    QObject::connect(&hello, SIGNAL(clicked()),
        &app, SLOT(quit()));
    hello.show();
    return app.exec();
}

Create the .pro file by running:

qmake -project

Now create the Makefile (and a couple of S60 specific files):

qmake

Finally, build the project and generate a (self-signed) SIS file for it:

make release-gcce # or release-armv5, if using RVCT
make sis

The SIS file will be created on the current directory with the name “<project>_release-<platform>.sis”, where <project> is the project name and <platform> is the S60 platform (either gcce or armv5).

TODO

  • Test the compiled Qt on the device
Follow

Get every new post delivered to your Inbox.