Setting up an Amiga Cross Compiler (Linux/Mac)

VBCC is a great option, since it’s still being maintained and developed. Plus, the executables it produces are usually smaller than GCC’s and comparable to those of SAS/C’s.

I’ve noticed that getting it, setting it up and compiling your first program is not as well documented as I would like. So I decided to write this post, hopefully helping someone else if they get stuck as well.

The instructions below are for a Linux environment, they will also work on MacOS X. A Windows one will follow shortly.

Note: We’re creating the “objects” directory because the Makefile is expecting it to be there. It will fail if it’s not. Once it’s compiled, we will need to copy the binaries to the location we’ll be placing VBCC into (as mentioned above, I chose /opt/vbcc/bin).

Note: As you noticed, we created the “bin” directory manually. That’s because the Makefile will try to place the binaries in it, but will not create it itself. It will fail if the directory does not exist.

Once it’s compiled, we need to copy these binaries as well:

sudo cp bin/vbcc* bin/vc bin/vprof /opt/vbcc/bin

Almost done! All we need now is the target binaries for the platforms we want to compile (e.g. AmigaOS 68k, AmigaOS4, MorphOS, etc.). I will show an example for AmigaOS 68k, but the pattern is the same for the other platforms as well.

As usual, we need to extract the archives. If you don’t have Lha in Linux, try installing “lhasa” (sudo apt-get install lhasa) or find an archive manager that can handle this format. On MacOS X, you can use “The Unarchiver” or take a look at MacPorts.

lha x vbcc_target_m68k-amigaos.lha
unzip vbcc_unix_config.zip

Now we need to copy the files to the right directory.

sudo mv config $VBCC/
sudo mv vbcc_target_m68k-amigaos/targets $VBCC/

And as a final step, let’s add the VBCC binaries to the system PATH, so that we can call them from anywhere:

export PATH=$VBCC/bin:$PATH

At this point, we are ready to compile C programs for the Amiga platform! Let’s try the classic Hello World program to test things out. Open up your favorite text editor and type the following:

#include <stdio.h>
main()
{
printf(“hello, world!\n”);
}

Save the above as “hello.c”, open a terminal to that location and type the following to compile it:

vc +aos68k -o hello hello.c

If you got no errors, you will end up with an Amiga executable file. You can check the results by typing “file hello”, like this:

file hello
hello: AmigaOS loadseg()ble executable/binary

Last but not least, you may want to install the AmigaOS 3.9 NDK files as well as any other SDK you want to use (e.g. AmigaOS4 SDK, Roadshow SDK etc.). Also, the PosixLib available on Aminet is a good supplementary .lib to have with VBCC. Those will have to be copied to a location of your choosing, then added in the Include and Link paths with the relevant commands.

Again, it’s easier if we use environment variables for these, like so: