Category:How to - Build helloworld

From Gumstix User Wiki
Revision as of 01:45, 14 June 2010 by Sellis (Talk | contribs) (wording)

Jump to: navigation, search


What follows is a description for building C programs on a workstation using the cross-build tools of OpenEmbedded, but NOT USING the bitbake/recipe framework.

For an alternative method USING the bitbake/recipe framework, a series of sample recipes can be found here.


Follow the instructions for setting up a build environment to get the cross-build tools correctly installed.

The tools are built under the TMPDIR directory declared in ${OVEROTOP}/build/conf/site.conf.

TMPDIR defaults to ${OVEROTOP}/tmp, but you can point it somewhere else.


After you have built an image, the cross-tools will be installed on your workstation.

You can now create a standard makefile for your project pointing to this cross-build toolchain.

Here is a simple example for helloworld.

# Makefile for building with the OE cross tools 
# OVEROTOP is normally ${HOME}/overo-oe 
# OETMP is the same as TMPDIR as defined in ${OVEROTOP}/build/conf/site.conf


TOOLDIR = ${OETMP}/cross/armv7a/bin

STAGEDIR = ${OETMP}/staging/armv7a-angstrom-linux-gnueabi/usr

CC = ${TOOLDIR}/arm-angstrom-linux-gnueabi-gcc

CFLAGS = -Wall  


INCDIR = ${STAGEDIR}/include      
TARGET = helloworld

OBJS = helloworld.o 

        ${CC} ${CFLAGS} ${OBJS} -L ${LIBDIR} -o ${TARGET}

helloworld.o: helloworld.c 
        ${CC} ${CFLAGS} -I ${INCDIR} -c helloworld.c  

        rm -f ${TARGET} ${OBJS} *~


After building with make, copy the resulting target executable to the overo.

Here are some alternatives.

1. If you are using a microSD card, copy your executable to the rootfs before you unmount it in the final step.

2. If you have a network connection to the overo, use scp.

3. If you are doing a network boot then copy the executable directly to the nfs exported root filesystem the gumstix is using on the workstation.

Only the Tools

You don't need to build a complete image to get the cross-tools.

If you only want to cross compile a C program without third-party dependencies, then you can build just the gcc-cross recipe.

bitbake gcc-cross

You can use OE to selectively build additional cross-compiled libraries as needed. Look around in the OE recipes folder.

For example, if you needed the kernel headers too...

bitbake linux-libc-headers

If you build a complete image, then most of the cross-build tools and libraries will get installed as as side-effect. That is probably the easiest way to setup your workstation the first time.

This category currently contains no pages or media.