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.
First step, we need to get vasm from the official site and compile it from the sources. The file we need is http://sun.hasenbraten.de/vasm/release/vasm.tar.gz
After the file is downloaded, open a terminal and navigate to where you have the file. Then type the following to extract it:
tar xvfz vasm.tar.gz
Compile it with the following:
make CPU=m68k SYNTAX=mot
Once that is done, we need to copy the binaries to a location we’ll be installing it to. I chose to place them in /opt/vbcc/bin, but you can choose any location you like of course:
sudo mkdir -p /opt/vbcc/bin
sudo cp vasmm68k_mot vobjdump /opt/vbcc/bin
Also, we’ll setup an Environment Variable so that we can reference that location easier from now on:
And with that, our Assembler is ready! Let’s move on to the next step.
Second step, we need to get vlink from the official site and compile it from source as well. The file we need is http://sun.hasenbraten.de/vlink/release/vlink.tar.gz
After the file is downloaded, extract it using the following:
tar xvfz vlink.tar.gz
Then let’s go in the directory and compile it:
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).
sudo mkdir -p /opt/vbcc/bin
sudo cp vlink /opt/vbcc/bin
Again, extract the archive first:
tar xvfz vbcc.tar.gz
The move into the directory and compile it:
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.
In order to setup at least one target environment for our compiler, we need to download some more packages. The official site is http://sun.hasenbraten.de/vbcc/ and we should get the latest binary package for the platform(s) we want. In my case that is http://server.owl.de/~frank/vbcc/2014-12-30/vbcc_target_m68k-amigaos.lha
Besides that, we’ll need a configuration for our platform, and thankfully there’s one already provided on the website. Get this file also: http://server.owl.de/~frank/vbcc/2014-12-30/vbcc_unix_config.tar.gz
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
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:
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:
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:
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:
To use the NDK, a typical command to compile a file would look like this:
vc +aos68k -I$NDK_INC -L$NDK_LIB -o test test.c -lamiga
More details on syntax options are of course available on the official manual. Happy coding!