The video above shows you how to get a cross-compiler for AmigaOS 4 up and running on your machine quickly. Here's a short summary of how it's done...

Setup Docker Containers

First, download and install Docker (https://docs.docker.com/get-docker/). They have installation instructions for multiple platforms, so find yours and follow it.

Next, we need a Docker container that contains a cross-compiler for AmigaOS. There are a few options floating out there. I've decided to use Walkero's containers, which you can find here (link). He provides containers with multiple versions of GCC, complete with the latest AmigaOS 4 SDK, and some common extras.

Let's set up the GCC 11 container using Docker compose. Create a directory for your AmigaOS projects. Inside that directory, create a file called docker-compose.yml, and copy and paste the following code:

version: '3'

services:
  gcc11-ppc:
    image: 'walkero/amigagccondocker:os4-gcc11-adtools'
    volumes:
      - '..:/opt/code'

This file defines a container called gcc11-ppc, that uses Walkero's AmigaOS4 GCC11 cross-compiler image. The volumes lines map the directory containing docker-compose.yml to the /opt/code subdirectory in the container. This gives the container access to the source code (very important, or it won't be able to access and compile your code).

You could add GCC 8 containers to the configuration file. But, realistically, you're unlikely to need anything other than GCC 11.

Now open a terminal window, CD into the directory containing the docker-compose.yml config file, and enter the following:

docker-compose up -d

Since this is the first time, Docker now fetches the image from the docker hub, and sets up the container. Once it's done, enter the following to run a bash shell in the container:

docker-compose exec gcc11-ppc bash

We're now running a bash shell inside the container. From here you can switch to any AmigaOS code project that you have stored inside the directory you created, and build it as you would on an AmigaOS machine.

Writing Cross-Compile Ready Makefiles

The cross-compiling container that we're using has gcc mapped directly to the cross-compiler, but normally it's the platform's own native compiler. On some systems you could even have multiple cross-compilers for different OSes side-by-side.

We want to make sure that the PowerPC AmigaOS compiler is used. This is done by adding a CPU and OS specific prefix to the compiler tools.

Here's an example from one of my makefiles:

OSPREFIX ?= ppc-amigaos-

# Set the compiler tools
CC = $(OSPREFIX)gcc
CXX = $(OSPREFIX)g++
LD = $(CXX)# Use the C++ compiler as linker for convenience
STRIP = $(OSPREFIX)strip

Notice how it uses ppc-amigaos-gcc and g++ instead of plain gcc. The same is true for the strip tool, or any other tool for that matter (e.g., ppc-amigaos-addr2line).

Final Comments

Congratulations! You have a fully working (but basic) cross-compiler setup for AmigaOS. You can fire-up your favourite code editor and get to work.

There's still room for improvement though. It would be nice if we could build the code directly from our code editor or IDE (e.g., directly from VS Code). And what about copying the files to an Amiga for testing? 

Both of those are possible. I'll show you how in future episodes...

Support Creating Amiga Content & Software

Want to support more Amiga content like this? Join the Kea Campus (click here). You'll support more Amiga content (and software). As a bonus, you'll see everything first, and get an insider's view. Just mention that you're an Amiga fan in your welcome post.

Click here to join the campus...