KDE on scratchbox for maemo 4

(with SUSE 11.2 you do not get the "happy hacking" message, because a lot of errors in dpkg)
 
(46 intermediate revisions not shown)
Line 1: Line 1:
This article describes how to compile KDE for maemo. It takes the Nokia N810 as example device. It uses the cross-compiling environment scratchbox on an Intel-based computer.  
This article describes how to compile KDE for maemo. It takes the Nokia N810 as example device. It uses the cross-compiling environment scratchbox on an Intel-based computer.  
 +
 +
{|align="right"
 +
    |[[image:Snapshot-ktimetracker-n810.jpg|thumb|400px|Many KDE applications can run on maemo, here: [http://userbase.kde.org/ktimetracker ktimetracker] (click to enlarge).]]
 +
    |}
== Overview ==
== Overview ==
Line 23: Line 27:
* Set up VMWare Server 2.0
* Set up VMWare Server 2.0
* Install a virtual machine into VMWare Server, 40GB hard drive, 1024 GB RAM
* Install a virtual machine into VMWare Server, 40GB hard drive, 1024 GB RAM
-
* Install SUSE Linux 11.2 from DVD. At the bootscreen, type F7 and select '''X86''' instead of '''X86_64'''. That way, you will get a 32bit operating system.
+
* Install SUSE Linux 11.1 from DVD. At the bootscreen, type F7 and select '''X86''' instead of '''X86_64'''. That way, you will get a 32bit operating system.
* Take a VMware SNAPSHOT from your virtual machine so you can revert to this state
* Take a VMware SNAPSHOT from your virtual machine so you can revert to this state
* Boot your virtual machine
* Boot your virtual machine
Line 44: Line 48:
== Re-login ==
== Re-login ==
To re-login after a reboot of your virtual machine run
To re-login after a reboot of your virtual machine run
-
  /scratchbox/sbin/sbox_ctl start
+
  root@i386 $ /scratchbox/sbin/sbox_ctl start
-
  /scratchbox/login
+
  root@i386 $ su - scratchboxuser
 +
scratchboxuser@i386 $ /scratchbox/login
== Hello world ==
== Hello world ==
Line 74: Line 79:
  apt-get install libqt4-dev
  apt-get install libqt4-dev
verify it has been installed:
verify it has been installed:
-
  ls /usr/include/qt4/
+
  mkdir qttest
-
  Qt          QtAssistant QtDBus      QtGui  QtNetwork QtScriptTools QtSvg  QtUiTools QtXml
+
cd qttest/
-
  Qt3Support QtCore      QtDesigner QtHelp QtScript  QtSql          QtTest QtWebKit  QtXmlPatterns
+
cat >main.cpp
-
verify it does not work:
+
#include <QApplication>
-
  qmake
+
#include <QPushButton>
-
  mmap: Permission denied
+
int main(int argc, char ** argv)
 +
{
 +
  QApplication qa(argc,argv);
 +
  QPushButton* qp=new QPushButton("hello world");
 +
  qp->show();
 +
  return qa.exec();
 +
}
 +
qmake -project && qmake && make && ./qttest
 +
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/targets/DIABLO_ARMEL/usr/share/qt4/mkspecs/linux-g++ -I. -I/targets/DIABLO_ARMEL/usr/include/qt4/QtCore -I/targets/DIABLO_ARMEL/usr/include/qt4/QtGui -I/targets/DIABLO_ARMEL/usr/include/qt4 -I. -I. -o main.o main.cpp
 +
  g++ -Wl,-O1 -o qttest main.o    -L/usr/lib -lQtGui -lQtCore -lpthread
 +
  qttest: cannot connect to X server
 +
 
 +
Good - it tries to connect the X server, so it works.
 +
 
 +
== See graphics ==
 +
To see graphics, you need to start Xephyr. This example shows how to install and run it on SUSE Linux 11.1.
 +
  root@i386 $ yast -i xorg-x11-server-extra
 +
  root@i386 $ Xephyr :4
 +
Now back in your scratchbox
 +
  [sbox-DIABLO_ARMEL: ~/qttest] > export DISPLAY=:4
 +
  [sbox-DIABLO_ARMEL: ~/qttest] > ./qttest
 +
Now you should see a "hello world" button in a graphical window.
 +
 
 +
== Install cmake ==
 +
  [sbox-DIABLO_ARMEL: ~/qttest] > wget http://www.cmake.org/files/v2.6/cmake-2.6.2.tar.gz
 +
  [sbox-DIABLO_ARMEL: ~/qttest] > tar xvzf cmake-2.6.2.tar.gz
 +
  [sbox-DIABLO_ARMEL: ~/qttest] > cd cmake-2.6.2
 +
  [sbox-DIABLO_ARMEL: ~/qttest] > ./bootstrap && make -j4 && make install
 +
I ran into [http://www.cmake.org/pipermail/cmake/2009-February/027065.html this issue], so I created link.txt by compiling cmake in a non-scratchbox environment and copying it over.
 +
 
 +
== shared-mime-info ==
 +
Shared-mime-info 0.2 or greater is needed for KDE.
 +
[sbox-DIABLO_ARMEL: ~] > cd
 +
[sbox-DIABLO_ARMEL: ~] > wget http://freedesktop.org/~hadess/shared-mime-info-0.20.tar.bz2
 +
[sbox-DIABLO_ARMEL: ~] > bunzip2 shared-mime-info-0.20.tar.bz2
 +
[sbox-DIABLO_ARMEL: ~] > tar xvf shared-mime-info-0.20.tar
 +
[sbox-DIABLO_ARMEL: ~] > cd shared-mime-info-0.20
 +
[sbox-DIABLO_ARMEL: ~] > ./configure && make && make install
 +
Make sure version 0.2 is in place:
 +
[sbox-DIABLO_ARMEL: ~] > update-mime-database -v
 +
update-mime-database (shared-mime-info) 0.19
 +
[...]
 +
[sbox-DIABLO_ARMEL: ~] > export PATH=/usr/local/bin:$PATH
 +
[sbox-DIABLO_ARMEL: ~] > update-mime-database -v
 +
update-mime-database (shared-mime-info) 0.20
 +
[...]
 +
 
 +
== kdesupport ==
 +
Compile kdesupport
 +
apt-get install libboost-dev
 +
apt-get install libboost-program-options-dev
 +
apt-get install xsltproc
 +
svn co https://svn.kde.org/home/kde/trunk/kdesupport
 +
cd kdesupport
 +
cmake . && make
 +
If you again get the error about a missing link.txt, try copying /scratcbox/devkits/qemu/bin/qemu-arm-sb from a fremantle installation to /scratchbox/devkits/cputransp/bin and configure your target configuration to use this
 +
make install
 +
 
 +
== pcre ==
 +
PCRE is needed for kdelibs
 +
cd
 +
curl ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz>pcre-7.9.tar.gz
 +
tar xvzf pcre-7.9.tar.gz
 +
cd pcre-7.9
 +
./configure && make && make install
 +
 
 +
== libXslt ==
 +
libxslt is needed for kdelibs
 +
cd
 +
curl ftp://xmlsoft.org/libxslt/libxslt-1.1.26.tar.gz>libxslt-1.1.26.tar.gz
 +
tar xvzf libxslt-1.1.26.tar.gz
 +
cd libxslt-1.1.26
 +
./configure && make && make install
 +
 
 +
== libgif-devel ==
 +
apt-get install giflib-dev
 +
 
 +
== kdelibs ==
 +
cd
 +
svn co https://svn.kde.org/home/kde/branches/KDE/4.1/kdelibs
 +
mkdir kdelibs-build
 +
cd kdelibs-build
 +
cmake ../kdelibs && make && make install
 +
 
 +
[sbox-DIABLO_ARMEL: ~/kdelibs-build] >
 +
[sbox-DIABLO_ARMEL: ~/kdelibs-build] > kde4-config --version
 +
Qt: 4.5.2
 +
KDE: 4.1.4 (KDE 4.1.4)
 +
kde4-config(8125) KLocalePrivate::initEncoding: Cannot resolve system encoding, defaulting to ISO 8859-1.
 +
kde4-config: 1.0
 +
 
 +
Congratulations! Your first kde 4 software is running :)
 +
 
 +
== gpgme ==
 +
gpgme is needed for kdepimlibs.
 +
apt-get install libgpgme11-dev libgpg-error-dev
 +
 
 +
== kdepimlibs ==
 +
cd                                                               
 +
svn co https://svn.kde.org/home/kde/branches/KDE/4.1/kdepimlibs
 +
cd kdepimlibs
 +
cmake . && make && make install
 +
 
 +
== checkinstall ==
 +
Checkinstall is needed to build packages that we will copy.
 +
wget http://www.asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz
 +
tar xvzf checkinstall-1.6.2.tar.gz
 +
make
 +
make install
 +
Repair installwatch
 +
vi /usr/local/bin/installwatch
 +
Set
 +
FAIL=1
 +
to
 +
FAIL=0
 +
 
 +
== ktimetracker ==
 +
As example application that we want to run on the N810, we take ktimetracker from the KDEPIM package. So, checkout kdepim
 +
cd
 +
svn co https://svn.kde.org/home/kde/branches/KDE/4.1/kdepim
 +
cd kdepim
 +
cmake . && make
 +
This results in an error, however we go on:
 +
cd ktimetracker
 +
make
 +
Now, as checkinstall does not work, we manually put the dependencies into a package:
 +
  ldd ktimetracker
 +
Copy all the files into /root/slash on the N810. Copy the file ktimetracker there. Copy the menu file /usr/local/share/apps/ktimetracker/karmui.rc there.
 +
 
 +
= back on the N810 =
 +
  cd /root/slash
 +
export LD_LIBRARY_PATH=.
 +
./ktimetracker
 +
 
 +
= Hints =
 +
 
 +
== How to make a screenshot ==
 +
Here is how you can trigger a screenshot from command line under maemo:
 +
apt-get install graphicsmagick
 +
[http://www.man-wiki.net/index.php/1:gm#GM_IMPORT gm import] -window root rootwindow.jpg
 +
 
 +
== How to use the SD storage ==
 +
If you want to store your KDE executables on the large /media/mmc1, you have to play some tricks. Remember that your N810 cannot format anything as ext2 (let alone ext3 and ext4). So you have to mount your mini SD card as vfat with all permissions set, so that every file is executable:
 +
cd
 +
umount /media/mmc1
 +
mount /dev/mmcblk1p1 /media/mmc1 -t vfat -o umask=000
 +
 
 +
= See also =
 +
* http://techbase.kde.org/Projects/Maemo/kdepim
 +
 
 +
[[Category:KDE]]
 +
[[Category:Diablo]]

Latest revision as of 14:00, 12 February 2010

This article describes how to compile KDE for maemo. It takes the Nokia N810 as example device. It uses the cross-compiling environment scratchbox on an Intel-based computer.

Many KDE applications can run on maemo, here: ktimetracker (click to enlarge).

Contents

[edit] Overview

  • maemo is the core software stack that runs on mobile devices like Nokia's N810 or N900
  • garage is where the projects for maemo are hosted, somewhat compareable to Sourceforge.
  • OS2008 is maemo 4.x (more info). Compare it with Debian's Lenny.
  • Diablo is the version (feature upgrade 2008) of maemo.
  • Scratchbox is a cross-compiling environment to enable you to create software for maemo on an i386.
  • Busybox is a single binary that allows you to run commands like ls, cat and bunzip2
  • Hildon is an application framework and desktop shell for maemo, compare it to the role that Plasma plays in KDE 4

[edit] On the Nokia itself

ssh root@localhost
apt-get install subversion

[edit] On your desktop

You cannot install scratchbox on an X64 computer, so, install an i386 into a VMWare virtual machine. The following describes how to install scratchbox into a SUSE 11.1 32bit installation. It might work same or similar with any Linux.

[edit] Set up scratchbox

First, we want to compile a "hello world" program for the Nokia. Here is how.

  • Set up VMWare Server 2.0
  • Install a virtual machine into VMWare Server, 40GB hard drive, 1024 GB RAM
  • Install SUSE Linux 11.1 from DVD. At the bootscreen, type F7 and select X86 instead of X86_64. That way, you will get a 32bit operating system.
  • Take a VMware SNAPSHOT from your virtual machine so you can revert to this state
  • Boot your virtual machine
  • Set up scratchbox
root@i386 # useradd -m scratchboxuser
root@i386 # passwd scratchboxuser
root@i386 # wget http://repository.maemo.org/stable/diablo/maemo-scratchbox-install_4.1.2.sh
root@i386 # chmod 777 maemo-scratchbox-install_4.1.2.sh
root@i386 # ./maemo-scratchbox-install_4.1.2.sh -s /scratchbox
root@i386 # /scratchbox/sbin/sbox_adduser scratchboxuser
root@i386 # su - scratchboxuser
  • set up the SDK
scratchboxuser@i386 $ wget http://repository.maemo.org/stable/diablo/maemo-sdk-install_4.1.2.sh

Start the install script and accept all choices:

scratchboxuser@i386 $ sh maemo-sdk-install_4.1.2.sh
  • start scratchbox
scratchboxuser@i386 $ /scratchbox/login
[sbox-DIABLO_ARMEL: ~] > sb-conf select DIABLO_ARMEL

[edit] Re-login

To re-login after a reboot of your virtual machine run

root@i386 $ /scratchbox/sbin/sbox_ctl start
root@i386 $ su - scratchboxuser
scratchboxuser@i386 $ /scratchbox/login

[edit] Hello world

Now we write the canonical hello world program in C.

[sbox-DIABLO_ARMEL: ~] > cat > main.c << EOF
#include <stdio.h>

int main()
{
  printf("hello world");
}
EOF
[sbox-DIABLO_ARMEL: ~] > gcc main.c
[sbox-DIABLO_ARMEL: ~] > file a.out
a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), not stripped
  • copy the file to your Nokia N810 using scp

=> the file is executable on the Nokia

[edit] Install Qt

Now it's time to install qt. Add to your /etc/apt/sources.list:

deb http://repository.maemo.org/extras/ diablo free non-free
deb-src http://repository.maemo.org/extras/ diablo free

and tell the system to re-read it:

apt-get update

install the qt development package:

apt-get install libqt4-dev

verify it has been installed:

mkdir qttest
cd qttest/
cat >main.cpp
#include <QApplication>
#include <QPushButton>
int main(int argc, char ** argv)
{
  QApplication qa(argc,argv);
  QPushButton* qp=new QPushButton("hello world");
  qp->show();
  return qa.exec();
}
qmake -project && qmake && make && ./qttest
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/targets/DIABLO_ARMEL/usr/share/qt4/mkspecs/linux-g++ -I. -I/targets/DIABLO_ARMEL/usr/include/qt4/QtCore -I/targets/DIABLO_ARMEL/usr/include/qt4/QtGui -I/targets/DIABLO_ARMEL/usr/include/qt4 -I. -I. -o main.o main.cpp
g++ -Wl,-O1 -o qttest main.o    -L/usr/lib -lQtGui -lQtCore -lpthread
qttest: cannot connect to X server

Good - it tries to connect the X server, so it works.

[edit] See graphics

To see graphics, you need to start Xephyr. This example shows how to install and run it on SUSE Linux 11.1.

root@i386 $ yast -i xorg-x11-server-extra
root@i386 $ Xephyr :4

Now back in your scratchbox

[sbox-DIABLO_ARMEL: ~/qttest] > export DISPLAY=:4
[sbox-DIABLO_ARMEL: ~/qttest] > ./qttest

Now you should see a "hello world" button in a graphical window.

[edit] Install cmake

[sbox-DIABLO_ARMEL: ~/qttest] > wget http://www.cmake.org/files/v2.6/cmake-2.6.2.tar.gz
[sbox-DIABLO_ARMEL: ~/qttest] > tar xvzf cmake-2.6.2.tar.gz
[sbox-DIABLO_ARMEL: ~/qttest] > cd cmake-2.6.2
[sbox-DIABLO_ARMEL: ~/qttest] > ./bootstrap && make -j4 && make install

I ran into this issue, so I created link.txt by compiling cmake in a non-scratchbox environment and copying it over.

[edit] shared-mime-info

Shared-mime-info 0.2 or greater is needed for KDE.

[sbox-DIABLO_ARMEL: ~] > cd
[sbox-DIABLO_ARMEL: ~] > wget http://freedesktop.org/~hadess/shared-mime-info-0.20.tar.bz2
[sbox-DIABLO_ARMEL: ~] > bunzip2 shared-mime-info-0.20.tar.bz2
[sbox-DIABLO_ARMEL: ~] > tar xvf shared-mime-info-0.20.tar
[sbox-DIABLO_ARMEL: ~] > cd shared-mime-info-0.20
[sbox-DIABLO_ARMEL: ~] > ./configure && make && make install

Make sure version 0.2 is in place:

[sbox-DIABLO_ARMEL: ~] > update-mime-database -v
update-mime-database (shared-mime-info) 0.19
[...]
[sbox-DIABLO_ARMEL: ~] > export PATH=/usr/local/bin:$PATH
[sbox-DIABLO_ARMEL: ~] > update-mime-database -v
update-mime-database (shared-mime-info) 0.20
[...]

[edit] kdesupport

Compile kdesupport

apt-get install libboost-dev
apt-get install libboost-program-options-dev
apt-get install xsltproc
svn co https://svn.kde.org/home/kde/trunk/kdesupport
cd kdesupport
cmake . && make

If you again get the error about a missing link.txt, try copying /scratcbox/devkits/qemu/bin/qemu-arm-sb from a fremantle installation to /scratchbox/devkits/cputransp/bin and configure your target configuration to use this

make install

[edit] pcre

PCRE is needed for kdelibs

cd
curl ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz>pcre-7.9.tar.gz
tar xvzf pcre-7.9.tar.gz
cd pcre-7.9
./configure && make && make install

[edit] libXslt

libxslt is needed for kdelibs

cd
curl ftp://xmlsoft.org/libxslt/libxslt-1.1.26.tar.gz>libxslt-1.1.26.tar.gz
tar xvzf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure && make && make install

[edit] libgif-devel

apt-get install giflib-dev

[edit] kdelibs

cd
svn co https://svn.kde.org/home/kde/branches/KDE/4.1/kdelibs
mkdir kdelibs-build
cd kdelibs-build
cmake ../kdelibs && make && make install
[sbox-DIABLO_ARMEL: ~/kdelibs-build] >
[sbox-DIABLO_ARMEL: ~/kdelibs-build] > kde4-config --version
Qt: 4.5.2
KDE: 4.1.4 (KDE 4.1.4)
kde4-config(8125) KLocalePrivate::initEncoding: Cannot resolve system encoding, defaulting to ISO 8859-1.
kde4-config: 1.0

Congratulations! Your first kde 4 software is running :)

[edit] gpgme

gpgme is needed for kdepimlibs.

apt-get install libgpgme11-dev libgpg-error-dev

[edit] kdepimlibs

cd                                                                 
svn co https://svn.kde.org/home/kde/branches/KDE/4.1/kdepimlibs
cd kdepimlibs
cmake . && make && make install

[edit] checkinstall

Checkinstall is needed to build packages that we will copy.

wget http://www.asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz
tar xvzf checkinstall-1.6.2.tar.gz
make
make install

Repair installwatch

vi /usr/local/bin/installwatch

Set

FAIL=1

to

FAIL=0

[edit] ktimetracker

As example application that we want to run on the N810, we take ktimetracker from the KDEPIM package. So, checkout kdepim

cd
svn co https://svn.kde.org/home/kde/branches/KDE/4.1/kdepim
cd kdepim
cmake . && make

This results in an error, however we go on:

cd ktimetracker
make

Now, as checkinstall does not work, we manually put the dependencies into a package:

ldd ktimetracker

Copy all the files into /root/slash on the N810. Copy the file ktimetracker there. Copy the menu file /usr/local/share/apps/ktimetracker/karmui.rc there.

[edit] back on the N810

cd /root/slash
export LD_LIBRARY_PATH=.
./ktimetracker

[edit] Hints

[edit] How to make a screenshot

Here is how you can trigger a screenshot from command line under maemo:

apt-get install graphicsmagick
gm import -window root rootwindow.jpg

[edit] How to use the SD storage

If you want to store your KDE executables on the large /media/mmc1, you have to play some tricks. Remember that your N810 cannot format anything as ext2 (let alone ext3 and ext4). So you have to mount your mini SD card as vfat with all permissions set, so that every file is executable:

cd 
umount /media/mmc1
mount /dev/mmcblk1p1 /media/mmc1 -t vfat -o umask=000

[edit] See also