Cross-compiling for AmigaOS 4.x

Valid HTML 4.01 Transitional


Introduction:

This is an unofficial guide to setup cross-compilers for AmigaOS 4.x. This document expects you to have some knowledge of linux or cygwin, as these are the plattforms used in this document.


The installation:

First you need to get the files for your plattform. Provided on this page are the following (only binaries, source is available at Amiga Development Tools):

If you find a bug please report it on http://sourceforge.net/projects/adtools/. There's a bugtracker there.

These archives should be unpacked into /usr/local. Normally done with 'tar jxf /path/to/binutils-2.18.tar.bz2' and 'tar jxf /path/to/gcc-4.2.4.tar.bz2' if /usr/local is the current directory. Make sure that there actually is an amiga dir there afterwards. After unpacking both binutils and gcc archives you're ready to setup the actual SDK. cd into /usr/local/amiga/ppc-amigaos, make a directory called SDK there, case is important. Now, make a link from /SDK to /usr/local/amiga/ppc-amigaos/SDK, this will make things easier if you want to compile linklibs and transfer them your regular SDK (/SDK will translate to SDK: on AmigaOS4). Finally you need to add it to the search path for commands. Enter this command in a shell, or add it to .bashrc (or any other place you seem fit): 'export PATH=/usr/local/amiga/bin:$PATH'. Once that's done, try this command: 'ppc-amigaos-gcc -v', it will tell you what version of ppc-amigaos-gcc you have installed.


/SDK

/SDK/clib2
/SDK/clib2/include
/SDK/clib2/lib
/SDK/clib2/lib.threadsafe

SDK/newlib
SDK/newlib/include
SDK/newlib/lib

/SDK/include
/SDK/include/include_h
/SDK/include/interfaces
/SDK/include/netinclude

/SDK/local

/SDK/local/clib2
/SDK/local/clib2/include
/SDK/local/clib2/lib

/SDK/local/newlib
/SDK/local/newlib/include
/SDK/local/newlib/lib

/SDK/local/ixemul
/SDK/local/ixemul/include
/SDK/local/ixemul/lib

/SDK/local/common
/SDK/local/common/include
/SDK/local/common/lib

The SDK:

Here is a good tutorial written by Nicolas Mendoza on UtilityBase.com on how to install the cross-compilers, including the SDK.

First you need to install clib2. Get the archive from http://sourceforge.net/projects/clib2/ and unpack into /SDK. Rename the resulting dir to clib2, it has the version number in the name when unpacked.

For newlib includes and libs, just copy those from your SDK install on OS4. Same goes for the OS4 includes and netincludes.

If you've done everything right it should look something like what's shown to the right. The layout of the /SDK directory is pretty much the same as with the native AmigaOS 4 SDK, so there shouldn't be any surprises there.

A few notes on the /SDK/local directory. It's recommended that you put third party stuff in there, like linklibs and includes, this will make upgrading clib2 or newlib a lot easier.In /SDK/local/clib2 are third party stuff that needs clib2, newlib stuff in /SDK/local/newlib and anything that's not using any libraries (or both?) in /SDK/local/common.


The test:

Now you're ready to test this beast. Just open you're editor of choice (vim for me, one of the reasons to cross-compile at all :) and enter this small program:


#include <stdio.h>
int main()
{
    printf("Hello World!\n");
    return(0);
}


Save as hello.c and issue this command: 'ppc-amigaos-gcc hello.c -o hello' ('ppc-amigaos-gcc hello.c -o hello -mcrt=clib2' to build using clib2 instead and use -mcrt=ixemul for ixemul binaries). If everything was setup correctly, this should've built the hello program for AmigaOS4.


The end:

It's all finished, you should be able to compile for AmigaOS4 now. If you need betatesters for your projects I suggest you visit #amigaworld or #amigadev on irc.amigaworld.net, or maybe you know some people that will test your programs for you. I would also like to recommend the following forums for AmigaOS4 development:


This document is (c) 2010 Joachim Birging