Aros/Developer/Docs/Examples/HelloWorld

From Wikibooks, open books for an open world
Jump to: navigation, search
Navbar for the Aros wikibook
Aros User Docs
Aros User Docs
Aros User FAQs
Aros User Applications
Aros User DOS Shell
Aros/User/AmigaLegacy
Aros Dev Docs
Aros Developer Docs
Porting Software from AmigaOS/SDL
For Zune Beginners
Zune .MUI Classes
For SDL Beginners
Aros Developer BuildSystem
Specific platforms
68k Support
PPC Power Architecture Support
Arm Raspberry Pi Support
Android support
Linux and FreeBSD Support
Windows Mingw and MacOSX Support
Aros x86 Installing
Aros x86 Audio/Video Support
Aros x86 Network Support
Aros x86 Complete System HCL
Aros Storage Support IDE SATA etc
Aros Poseidon USB Support
x86-64 Support
misc
Aros Public License









Description[edit]

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

The Code[edit]

#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 Compile[edit]

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 It[edit]

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

Aros-helloworld.png