< Aros‎ | Developer/Docs‎ | Examples


This is an example 'Hello World' program to demonstrate the basics of using c under AROS

The CodeEdit

#include <stdio.h>
int main(void)
    puts("Hello, world!");
    return 0;

Save this as a plain text file named 'helloworld.c'. Inside AROS you can do this by opening a shell (e.g. hit RightAROSKey* + w in Wanderer), typing 'edit helloworld.c', entering the code above, hit RightAROSKey + w to save it, hit RightAROSKey + q to quit editing.

(*on most keyboards RightAROSKey is the Windows key on the right side)

Making It CompileEdit

If you've created 'helloworld.c' inside AROS, compile it with:

 gcc -o helloworld helloworld.c

To cross-compile it from linux, provided you've got a proper SDK installed, making the executable helloworld program on AROS-linux-hosted takes this step:

i386-aros-gcc -o helloworld helloworld.c

In both cases, the result will be an executeable called 'helloworld', which should run under AROS.

Running ItEdit

In case you've cross-compiled from linux, move the executable into the AROS-linux-hosted installation tree, e.g. like this (assuming 'AROS/' is the root directory of AROS-linux-hosted, which corresponds to the 'System' partition inside AROS):

> mv helloworld AROS/

Inside AROS, find and run your executable via Wanderer, in our case: double-click 'System' icon on Wanderer desktop, double-click 'helloworld' icon (you might have to hold right mouse button and select 'Window -> View -> All Files' to see it). A window will be opened displaying the program's output.

Or, to run it from AROS' shell, assuming you're still in the same directory where you compiled it, just type it's name:

System:> helloworld