Compiling Amiga-Specific C (Part 4 of 5)

This is part four of a five-part series of posts on compiling Amiga-specific C code on an (emulated) Amiga A1200. We’ll start with a machine with an empty hard drive, and over the series, build up to compiling an Amiga-specific program which uses the graphics library.

Let’s go!

Compiling a simple Hello World program

This one should be a pretty simple one. We’re going to compile a simple Hello World program to basically ensure that we installed our compiler and include files correctly.

So, here’s the simple C program we’re going to be compiling. It’s very straight-forward:

#include <stdio.h>

int main(int argc, char** argv) {
    printf("Hello World, from the Amiga.\n");
    return 0;
}

AmigaOS comes complete with a text editor called memacs. While primitive by today’s standards, it was a great program for its time. Let’s fire it up by opening a Shell, changing to the RAM: directory, and editing a new file we’ll name hello.c.

Type in our program, before choosing “Save-Exit” from the Project menu.

The C compiler that comes as part of VBCC is actually called vc, and we want to specify an output file of hello by using the -o parameter.

3.Ram Disk:> vc hello.c -o hello

Assuming we didn’t get any errors, we can then run the program by executing hello, like this:

That’s really all there is to it. If you got errors when compiling, it’s worth checking S:user-startup to ensure that it contains the VBCC stuff below (the installer should have automatically added this).

;BEGIN vbcc
assign >NIL: vbcc: System:c_dev/vbcc
assign >NIL: C: vbcc:bin ADD
setenv VBCC vbcc:
;END vbcc
;BEGIN vbcc-m68k-amigaos
assign >NIL: vincludeos3: vbcc:targets/m68k-amigaos/include
assign >NIL: vincludeos3: "System:c_dev/NDK_3.9/Include/include_h" add
assign >NIL: vlibos3: vbcc:targets/m68k-amigaos/lib
;END vbcc-m68k-amigaos

So, to summarize, we’ve verified that the compiler is installed and working correctly, and can locate and use the standard include files. Next time, we’ll move on to our actual goal of compiling some Amiga-specific code!

Leave a comment

Your email address will not be published. Required fields are marked *