Setting up an Amiga Cross-Compiler (Windows) part 1 (original) (raw)

This is the Windows version, if you are running Linux or MacOS X, please check my other post about them here.

VBCC is an excellent compiler, still actively developed and supports multiple target platforms, including our favorite Amiga (and clones). While the procedure to get it installed on Linux/Mac is rather straightforward (you have to download the sources, then compile them), it can be a bit more tricky if you are on Windows. This post is meant to help with that, guiding through all the steps necessary to get your environment up and running with the minimum hassle.

The quick and easy approach

Since other people have gone through the same pain, it should be expected that someone has thought about simplifying the procedure and providing some shortcuts. There are now 2 different “easy” approaches (choose one):

  1. A Windows Installer package, by Leffmann: http://eab.abime.net/showthread.php?t=83113
  2. Erik Faye-Lund has created a package containing the latest pre-compiled binaries, along with the target platform and even the NDK and PosixLib packages included.

The steps to install this package are as follows:

  1. Head over to Github and download the package.
  2. Extract/install everything to “C:\amiga-dev\”.
  3. Add “C:\amiga-dev\bin\” to the system PATH environment variable.
  4. Set the “VBCC” environment variable to “C:\amiga-dev\targets\m68k-amigaos”.

Quite simple and straightforward, don’t you think?

Although the above “just works”, you can have more nerdy fun if you choose to compile everything from source yourself, potentially learning something along the way. If you are such a person, read on to the Advanced section below. Otherwise, you’re already good to go – write some code and experiment!

The advanced nerd approach

Some people like it easy. Some people prefer to go through the steps manually and fine-tune, learn and achieve that extra level of accomplishment once they get it to work. If you’re one of those people, this section is for you. 🙂

Requirements

Once you’ve got the above installed and/or updated, it’s time to start having fun. Follow these steps:

VBCC

First of all, we need to download the sources package. You can get the current snapshot archive from here. If you want to read more information about it, you can visit the official website: http://www.compilers.de/vbcc.html

Extract the archive somewhere, e.g. to

C:\vbcc

Next comes our first challenge. The included Makefile will not work out-of-the-box on Windows, since it was designed for Linux/Mac platforms originally, using the GCC compiler. There are things in there that need to change before we can use it, such as paths using forward slashes (“/”) which Windows does not understand and instead expects with backslashes (“\”).

For your convenience, here’s a modified Makefile including all the changes below. If you prefer to do it manually regardless, read on. Otherwise, skip to the next section – Compiling VBCC.

Open the Makefile with your Text Editor, save a copy of it with a new name (e.g. “MakefileVS.mak”) and make the following changes in it:

CC = gcc -std=c9x -g -DHAVE_AOS4 #-DHAVE_ECPP -DHAVE_MISRA

To this:

CC = cl /D_CRT_SECURE_NO_WARNINGS /nologo /O2 /MT /Zp1 /wd4715 /wd4068 /wd4048

LDFLAGS = -lm

it should now read:

LDFLAGS =

-o $(TRGDIR)/mbasic.o

should be replaced with this:

/Fo$(TRGDIR)/mbasic.o

but something like this should not be replaced (yet), since it does not specify a file name ending with “.o”:

-o bin/vc $(LDFLAGS)

“/link /NOLOGO /OUT:”

So for example, this line:

(CC)frontend/vc.c−obin/vc(CC) frontend/vc.c -o bin/vc (CC)frontend/vc.cobin/vc(LDFLAGS)

should be replaced with this:

(CC)frontendvc.c/link/NOLOGO/OUT:binvc(CC) frontend\vc.c /link /NOLOGO /OUT:bin\vc (CC)frontendvc.c/link/NOLOGO/OUT:binvc(LDFLAGS)

(CC)frontendvc.c/link/NOLOGO/OUT:binvc(CC) frontend\vc.c /link /NOLOGO /OUT:bin\vc (CC)frontendvc.c/link/NOLOGO/OUT:binvc(LDFLAGS)

should be amended like this:

(CC)frontendvc.c/link/NOLOGO/OUT:binvc.exe(CC) frontend\vc.c /link /NOLOGO /OUT:bin\vc.exe (CC)frontendvc.c/link/NOLOGO/OUT:binvc.exe(LDFLAGS)

bin\dtgen: datatypes\dtgen.c datatypes\datatypes.h datatypes\dtconv.h
(NCC)datatypesdtgen.c/link/NOLOGO/OUT:bindtgen.exe  /Idatatypes  (NCC) datatypes\dtgen.c /link /NOLOGO /OUT:bin\dtgen.exe /Idatatypes (NCC)datatypesdtgen.c/link/NOLOGO/OUT:bindtgen.exe  /Idatatypes  (NLDFLAGS)

Compiling VBCC

Now that the hard part is over, we can finally try to compile VBCC. Follow these steps to do so:

nmake /f MakefileVS bin\vc

nmake /f MakefileVS TARGET=m68k bin\vbccm68k

If all goes well, you should see a list of messages scroll by (but no errors) and finally the operation completes successfully, resulting in the executable files in the “bin” directory. Pat yourself in the back, we’ve been through the most difficult part. 🙂

In the next post, we’ll prepare and compile VLINK and VASM as well, after which we’ll have all the pieces together. Then we need to setup our environment and configure some Target platforms, before we can create our fist program.