Sample code/C/Hello World

From GumstixDocsWiki

Jump to: navigation, search

This page presents the classic C "Hello World" program

The source

The source code for the hello.c is presented here:

#include <stdio.h>

int main( int argc, char **argv )
{

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

There is also a simple Makefile which you can use as a starting point for creating your own Makefiles.

This Makefile assumes that you create a directory parallel to the gumstix-buildroot (i.e. on my system, gumstix-build root can be found at /home/dhylands/gumstix/gumstix-buildroot, so for the hello-world example, I'd create /home/dhylands/gumstix/hello-world).

Copy in the hello.c and Makefile into your hello-world directory and type make (SVN username password is root/root). You should see something like the following:

/home/dhylands/gumstix/hello-world/../gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclibc-gcc -O2 -M hello.c > .depend
/home/dhylands/gumstix/hello-world/../gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclibc-gcc -O2  -Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale -c -o hello.o hello.c
/home/dhylands/gumstix/hello-world/../gumstix-buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-uclibc-gcc  -Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale hello.o   -o hello

Note: This requires that you've already installed buildroot, which creates the toolchain required to compile the code.

Personal tools