Qt4 Maemo Binding

From Lazarus wiki
Jump to navigationJump to search

Qt4 Maemo Binding

This page describes the Free Pascal Qt4 Binding for Maemo.

Currently Maemo5 on the Nokia N900 version PR1.2 is supported. The binding is an interface to Qt 4.6.2 of the PR1.2 release.

Introduction

To develop with C++ Qt for the N900, Nokia provides a scratchbox based SDK: Maemo5 SDK Installation

The Free Pascal binding is technically just a Qt C++ library, so to compile this binding library, the scratchbox SDK is needed.

To develop with Free Pascal Qt for the N900, you do not need to install the complex scratchbox environment, you can use the provided binding binary.

Links


Compilation of the binding

These instructions explain how to compile the Free Pascal Qt4 Binding for Maemo sources. If you use the provided binary of the binding, this is not necessary.

  • Install the scratchbox based Maemo5 SDK: Maemo5 SDK Installation
  • After installation, start as root scratchbox: /scratchbox/sbin/sbox_ctl start
  • As normal user login: /scratchbox/login
  • select using sb-menu the arm environment
  • install the Qt4 devel package
    • fakeroot apt-get update
    • fakeroot apt-get install libqt4-dev
  • download (e.g. using wget) and unpack the sources
  • cd into the sources directory
  • qmake (creates Makefile)
  • make (compiles)
  • strip LibraryFileName (reduce filesize)
  • fakeroot make install (installs in scratchbox)

Installation on the N900 device

These instructions explain how to install the Free Pascal Qt4 Binding for Maemo on the Nokia N900 device.

How to setup a wifi or usb access to the device is out of the scope (see Nokia instructions) The instructions assume a working ssh access to the N900 using hostname n900.

First obtain the binding library (libQt4Pas.so.6.2.2) either from the provided binary or from compilation within scratchbox.

Note that it is possible to setup ssh from within scratchbox and ssh from scratchbox to the N900. You can also access the compiled library that resides in scratchbox outside the scratchbox environment. If you installed scratchbox to /scratchbox, then the scratchbox user home directory is located at /scratchbox/users/username/home/username/.


  • Copy the library to the device opt directory (optify)
scp libQt4Pas.so.6.2.2 root@n900:/opt/lib/
  • login to the device as root
ssh root@n900
  • create symlinks
ln -s /opt/lib/libQt4Pas.so.6.2.2 /usr/lib/libQt4Pas.so.6
ln -s /opt/lib/libQt4Pas.so.6.2.2 /usr/lib/libQt4Pas.so

Cross compile for N900

These instructions explain how to cross compile a Free Pascal Qt4 Maemo program from linux to N900.

Setup Cross Compilation

It is strongly advised to read the Free Pascal Docmumentation about cross compilation to understand what you do : Build Faq

The scratchbox SDK is not needed, only N900 binutils and some N900 device libraries are needed and will be copied to a directory named /arm


md /arm ; cd /arm
wget http://users.telenet.be/Jan.Van.hijfte/qtforfpc/n900-binutils.tar.gz
tar zxvf n900-binutils.tar.gz
rm -f n900-binutils.tar.gz
md -p lib ; scp root@n900:/lib/* lib
md -p usr/lib; scp root@n900:/usr/lib/* usr/lib

Make sure you already have a recent x86 fpc installed and a fpc subversion trunk available in e.g. /svn/fpc

cd /svn/fpc
make distclean
make crossinstall CPU_TARGET=arm OPT="-dFPC_ARMEL" BINUTILSPREFIX=arm-linux- CROSSBINDIR=/arm/binutils/ INSTALL_PREFIX=/usr
ln -sf /usr/lib/fpc/2.5.1/ppcrossarm /usr/bin/ppcarm

Add an arm section before the Parsing Switches section into fpc.cfg

#IFDEF CPUARM
 -g
 -gl
 -O-
 -dFPC_ARMEL 
 -dMAEMO5
 -XParm-linux-
 -FD/arm/binutils/
 -Xd
 -Fl/arm/lib
 -Fl/arm/usr/lib
 -XR/arm/
 -Xr/arm/lib/
 -Xr/arm/usr/lib/
 -k-rpath /arm/lib
 -k-rpath /arm/usr/lib
 -k-L/arm/lib
 -k-L/arm/usr/lib
#ENDIF

Compile and Run the Binding Maemo Demo

Download Demo source and compile

wget http://users.telenet.be/Jan.Van.hijfte/qtforfpc/maemo5_demos-V2.2_Qt4.6.2.tar.gz
tar zxvf maemo5_demos-V2.2_Qt4.6.2.tar.gz
cd demos-V2.2_Qt4.6.2
cd maemowidgets
ppcarm maemowidgets

Transfer executable on device and run

scp maemowidgets root@n900:/opt/
ssh root@n900
cd /opt
./maemowidgets