jump to navigation

Python tutorial: Accessing APIs without Python bindings February 2, 2010

Posted by lizardo in General.
Tags: ,
add a comment

The PyMaemo team has prepared a short tutorial with an actual example on how to access APIs for which there are no Python bindings yet. libosso-abook was used as an example, but in practice, you can access any C libraries using the same approach. This technique can be used while we do not finish implementing the full Maemo API.

Enjoy. :)

Installing Qt for Symbian SDK 4.6.1 on Linux January 21, 2010

Posted by lizardo in Linux.
Tags: , , ,
18 comments

Update (2010-01-27): New version of Qt installer (v2).

Qt 4.6.1 was released last Tuesday, so I took some time to update my Linux support patches for Qt (which are now merged in qt-s60 tree and hopefully will be in main Qt tree at some point) and GnuPoc (which, thanks to Martin, are now integrated into the latest release).

I had a couple of previous posts detailing instructions on how to install the SDK on Linux, but after some time, it became too boring to run those commands manually, and some people asked for a script. So, from now on, I will provide two installers to make the process much more automated and simple: one installer for GnuPoc + Open C/C++ plugin, and another for the Qt for Symbian SDK.

Note that currently the GnuPoc installer handles only the S60 5.0 SDK. If someone is interested on a 3.1 SDK installer let me know so I can add support for it too.

Preparation

Download all required files to a single directory (e.g. “~/downloads”):

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

First, install GnuPoc + S60 5.0 SDK + the Open C/C++ plugin:

./gnupoc_1.15_S60_5.0_installer_v1.sh \
    <download-dir> \
    <gnupoc-dir>

Replace <download-dir> with the location of all files downloaded in previous section (e.g. “~/downloads”), and <gnupoc-dir> with the destination directory for GnuPoc and the SDK files (e.g. “~/gnupoc”). Note that both directories must have absolute paths.

If installation was successful, you should see an output like:

Installation has finished. Before using the GnuPoc SDK, run these commands on the console:
 
export PATH=<gnupoc-dir>/bin:$PATH
export EPOCROOT=<gnupoc-dir>/symbian-sdks/5.0/ # trailing "/" is required!
 
(These commands must be run again every time a new console is opened.)

Run the commands as instructed on the message. Next, install Qt for Symbian:

./qt_for_symbian_4.6.1_linux_installer_v2.sh \
    <download-dir> \
    <qt-s60-dir>

Replace <download-dir> with the location of all files downloaded in previous section (e.g. “~/downloads”), and <qt-s60-dir> with the destination directory for the Qt files (e.g. “~/gnupoc/qt-4.6.1″). Note that both directories must have absolute paths.

If installation was successful, you should see an output like:
Installation has finished. Before using the Qt for Symbian SDK, run this command on the console:
 
export PATH=<qt-s60-dir>/bin:$PATH
 
(This command must be run again every time a new console is opened.)

Before using Qt for Symbian, you should run the command as instructed on the message above.

Usage example

To test the installation, I will describe how to build the “colliding mice” example.

  1. cd into the example source:
  2. cd <qt-s60-dir>/examples/graphicsview/collidingmice/

  3. Open collidingmice.pro and replace these two lines:
  4.     TARGET.UID3 = 0xA000A643
        include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)

    with:
        TARGET.UID3 = 0xE000A643
    In other words: replace the UID3 “0xA000A643″ with “0xE000A643″ and remove (or comment out) the “include(…)” line. This will allow to sign the built SIS file using a self-signed certificate, otherwise you would need a R&D certificate.

  5. Now build the example and generate the SIS file
  6. qmake
    make debug-gcce
    make sis

A few notes:

  • Only the “debug-gcce” (if you are using the GCCE toolchain AKA “CodeSourcery toolchain”) or “debug-armv5″ (if you are using RVCT) will work, because the 4.6.1 release only ships debug versions of the libraries
  • Make sure you do similar changes as described above if you want to try compiling other Qt examples. Otherwise, you will receive errors like “Unable to install” while trying to install the SIS file on the phone.

Installing Qt for Symbian on Linux September 24, 2009

Posted by lizardo in General.
Tags: , , ,
6 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

PySide released! August 18, 2009

Posted by lizardo in General.
Tags: , ,
add a comment

From the original announcement:

PySide is a project providing an LGPL’d set of Python bindings for the Qt framework.

PySide already provides a full set of Qt bindings as well as automated binding generation tools. Since the whole toolset has been made available, the team expects PySide to be valuable not only to Qt software developers, but to people willing to create Python bindings to any Qt-based library, or to any C++ library in general. Although based on a different technical approach, PySide will initially be API-compatible with existing Python bindings for Qt.

PySide is still a work in progress, and some work is still required to stabilize the codebase. This being said, the team believes it is already in a usable state, especially if an occasional rough edge and unpainted surface can be tolerated. Due to practical reasons, the initial development efforts have been focused on Linux, but the team hopes people to join in porting the code to other platforms and to further develop the bindings and tools.

So if you are interested in creating Python bindings for Qt based C++ code or (soon) other generic C++ code, feel free to try out PySide tools and contribute to its development :D .

Running Qt for S60 SDK on Linux July 29, 2009

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

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

 

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)

Making icecream monitor (icemon) work on Jaunty May 21, 2009

Posted by lizardo in Debian/Ubuntu, Hints.
Tags:
add a comment

While I have been using Ubuntu 8.04 LTS (hardy) in my work laptop (for the very same reasons I used dapper for a long time), I knew that some Ubuntu 9.04 (jaunty) users were having problems with icemon (the icecream monitor) not working, i.e., not showing any nodes. I did not investigate the reasons behind this, but a colleague reported that he could successfully make it work by using the older version from intrepid.

So here goes a small how-to on installing the older icecc-monitor version (from intrepid) in jaunty:

  1. Download the icecc-monitor .deb package from http://packages.ubuntu.com/intrepid/i386/icecc-monitor/download
  2. Install the package with:
  3. $ sudo dpkg -i icecc-monitor_*.deb

  4. The step above will successfully install the package, but in a future whole-system upgrade, it will again install the newer (buggy) version. To avoid that, you can tell dpkg to lock the package version, using the following command:
  5. $ echo icecc-monitor hold | sudo dpkg --set-selections

    If necessary, you can unlock it anytime using the command:

    $ echo icecc-monitor install | sudo dpkg --set-selections

I did not check yet whether this has already been reported to the Launchpad, if anyone knows, feel free to comment.

“undefined reference to `vtable for …’ errors” in Qt derived classes April 24, 2009

Posted by lizardo in Hints.
Tags:
2 comments

If you ever come across an error like this when compiling C++ code with Qt derived class definitions:


g++ -Wl,--no-undefined -o test test.o -L/usr/lib -lQtGui -lQtCore -lpthread
test.o: In function `main':
test.cpp:(.text+0x2c): undefined reference to `vtable for MyClass'
collect2: ld returned 1 exit status
make: *** [test] Error 1

It is probably because either you defined a class in a .cpp file or you forgot to add some header file to the HEADERS variable in the .pro file.

This happens because moc (Qt’s meta-object compiler) only runs on header files by default (and only on those listed in the HEADERS variable), therefore it did not generate the necessary MOC code for that class.

The fix is to simply move the class definition to a header, and make sure it is added to the HEADERS variable in the qmake project file.

Setting up libc6 sources for analysis on Debian/Ubuntu May 31, 2008

Posted by lizardo in Debian/Ubuntu, Linux.
add a comment

I used to work on development of a tracing tool at work, that required me reading some glibc code to understand internals of core library functions (following the “Use the source, Luke” Open Source principle for developer documentation). I use Ubuntu, so it seemed simpler to use its glibc sources so I don’t have to recompile glibc myself. Here are the instructions I use for setting up my environment for glibc code navigation (tested on Hardy running on x86):

# gcc 4.2 is required to configure libc6
$ sudo apt-get install build-essential gcc-4.2

# download sources
$ sudo apt-get source libc6
$ cd glibc-2.6.1/

# the "configure_i686" rule also calls other rules that
# unpack the sources and apply distro-specific patches
$ ./debian/rules configure_i686

# create a tags file to easily navigate between functions with Vim
$ cd build-tree/glibc-2.6.1/ && ctags -R --exclude=.pc

My Boomerang TODO list April 5, 2008

Posted by lizardo in Reverse Engineering.
4 comments

I have some items on my TODO list regarding Boomerang. Here they are:

  • migrate functional testsuite to DejaGNU (on progress)
  • increase test code coverage by writing new tests
  • update/fix/extend unit tests

Migration to dejagnu will allow to write more flexible functional tests, such as ones to test for error handling. Right now, Boomerang’s functional testsuite only covers the decompilation phase (as far as I can see), and only covers 48.1% of code (according to gcov/lcov). Next, I plan to increase this coverage percentage by writing new tests (and understanding the code a bit more on the way) and finally, once I start getting hands dirty on coding, I will fix/extend unit tests.

These are my short term plans. Long term plans are (not detailed yet): remove dependency on some (old, unmaintained) third-party tools, such as NJMC toolkit and old bison++/flex++ (this needs to be discussed on the mailing list); reuse code where possible, instead of reimplementing things like the PE/ELF/etc. parsers; make boomerang more modular, possibly allowing to compile it as a shared library (already possible?) or replacing some algorithms; take a look at DCC code (now GPL licensed); experiment with new concepts on the RE/Decompilation research field.