The Mer Wiki now uses your Mer user account and password (create account on https://bugs.merproject.org/)


Platform SDK and SB2

From Mer Wiki
Revision as of 09:11, 12 March 2012 by Lbt (Talk | contribs)

Jump to: navigation, search

The most straightforward way to use Scratchbox2 is within the Mer Platform SDK. The information here assumes you have the SDK setup as described.

Compiling with the SDK (FIXME)

Cross compilation tools are not currently available in the SDK out of the box. To setup cross compiling for N950 (armv7hl) do the following inside the sdk chroot

sudo zypper ref
sudo zypper in scratchbox2 qemu-usermode

add repository containing cross compiler and install needed packages from there

sudo zypper ar http://releases.merproject.org/releases/0.20120209.1/builds/armv7hl/packages/ cross
sudo zypper ref
sudo zypper in cross-armv7hl-gcc cross-armv7hl-binutils

extract Nemo N950 rootfs to for example your home directory

mkdir -p $HOME/n950rootfs
cd $HOME/n950rootfs
sudo tar xjvf /path/to/nemo-n950-image.tar.bz2

Set file permissions for the n950 rootfs

sudo chown -R <your username> n950rootfs

you might also need to give write permissions to some places like bin, sbin and so on.

sudo chmod u+w bin

initialize scratchbox2

cd $HOME/n950rootfs
sb2-init -d -L --sysroot=/ -C --sysroot=/ -c /usr/bin/qemu-arm-dynamic nemo-n950 /opt/cross/bin/armv7hl-meego-linux-gnueabi-gcc

if you get an error compaining about tmp do

sudo chmod 777 /tmp

and try again. the compiler should now work but you are still missing libraries to compile against. Install what you need into the n950 rootfs by

sb2 -eR zypper ref
sb2 -eR zypper install ...

If the installation fails due to permission errors give your user write permissions to the places the packages are being installed and retry. After this you can compile for example a c hello world by

cat << "EOF" > hello.c
#include <stdio.h>
int main(int argc, char **argv)
{
   printf("Hello\n");
   return 0;
}
EOF

sb2 gcc hello.c -o hello

verify that the compilation worked

$ file hello
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.25, not stripped
$ sb2 ./hello 
Hello
Personal tools