Building a hello world application

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(+cat)
(Compiling it using bitbake)
Line 30: Line 30:
  
 
=== Compiling it using bitbake ===
 
=== Compiling it using bitbake ===
To be written
+
If you set your enviroment (I created a small script to do this, you could also add it to you .bashrc)
==== Creating an ipkg package ====
+
export OMDIR=/home/moko
To be written
+
export BBPATH=$OMDIR/build:$OMDIR/openmoko/trunk/oe:$OMDIR/openembedded
 +
You should be capable of
 +
cd $OMDIR/build
 +
bitbake nano
 +
This should auto-magically fetch the recipe for baking nano and baking it.<br>
 +
This results in some ipk packages being created in $OMDIR/build/tmp/deploy/ipk/armv4t/
 +
==== An OpenEmbedded guide to creating a hello world ====
 +
OpenEmbedded has a nice [[http://www.openembedded.org/user-manual&dpage=recipes_examples Wiki page]] on creating a hello world, I highly recommend it.
 +
 
 +
==== Creating an ipk package ====
 +
To be written ''(Perhaps this is done by the  do_install() function)''
  
 
[[Category:Software]]
 
[[Category:Software]]

Revision as of 17:25, 17 July 2007

Contents

Preparation

This guide assumes that you have performed the steps in Building_OpenMoko_from_scratch

The commandline program

Store the following more or less standard hello world code in hello.c

#include <stdio.h>

int main()
{
  printf ("Hello World\n");
  return 0;
}

Compiling it the wrong / easy way

Assuming your current working directory is /home/moko,
and that you stored the code in /home/moko/hello.c

It should now be possible to compile the application using

./build/tmp/cross/arm-linux/bin/gcc -o hello hello.c

Testing it

Assuming you have followed Setting up USB connection and you have a working network concetion to either a qemu Neo or a real Neo.

scp hello root@192.168.0.202:/tmp/
ssh root@192.168.0.202 /tmp/hello

This sequence of commands ought to give you a nice Hello World, btw. the default root password is blank, just press return.

Why was it the wrong way?

OpenMoko uses [OpenEmbedded] and they use bitbake when building stuff


Compiling it using bitbake

If you set your enviroment (I created a small script to do this, you could also add it to you .bashrc)

export OMDIR=/home/moko
export BBPATH=$OMDIR/build:$OMDIR/openmoko/trunk/oe:$OMDIR/openembedded

You should be capable of

cd $OMDIR/build
bitbake nano

This should auto-magically fetch the recipe for baking nano and baking it.
This results in some ipk packages being created in $OMDIR/build/tmp/deploy/ipk/armv4t/

An OpenEmbedded guide to creating a hello world

OpenEmbedded has a nice [Wiki page] on creating a hello world, I highly recommend it.

Creating an ipk package

To be written (Perhaps this is done by the do_install() function)

Personal tools

Preparation

This guide assumes that you have performed the steps in Building_OpenMoko_from_scratch

The commandline program

Store the following more or less standard hello world code in hello.c

#include <stdio.h>

int main()
{
  printf ("Hello World\n");
  return 0;
}

Compiling it the wrong / easy way

Assuming your current working directory is /home/moko,
and that you stored the code in /home/moko/hello.c

It should now be possible to compile the application using

./build/tmp/cross/arm-linux/bin/gcc -o hello hello.c

Testing it

Assuming you have followed Setting up USB connection and you have a working network concetion to either a qemu Neo or a real Neo.

scp hello root@192.168.0.202:/tmp/
ssh root@192.168.0.202 /tmp/hello

This sequence of commands ought to give you a nice Hello World, btw. the default root password is blank, just press return.

Why was it the wrong way?

OpenMoko uses [OpenEmbedded] and they use bitbake when building stuff


Compiling it using bitbake

If you set your enviroment (I created a small script to do this, you could also add it to you .bashrc)

export OMDIR=/home/moko
export BBPATH=$OMDIR/build:$OMDIR/openmoko/trunk/oe:$OMDIR/openembedded

You should be capable of

cd $OMDIR/build
bitbake nano

This should auto-magically fetch the recipe for baking nano and baking it.
This results in some ipk packages being created in $OMDIR/build/tmp/deploy/ipk/armv4t/

An OpenEmbedded guide to creating a hello world

OpenEmbedded has a nice [Wiki page] on creating a hello world, I highly recommend it.

Creating an ipk package

To be written (Perhaps this is done by the do_install() function)