In the previous post, we went through the steps to download, configure and compile VBCC on Windows. It’s time to move on to the next steps.
If you prefer to give up and go for the easy route, you can also download my compiled bin folder and use it. These were compiled on 2017-03-02 using Visual Studio 2017.
VLINK
Let’s begin by downloading the source files for the latest release, from the official site: http://sun.hasenbraten.de/vlink/index.php?view=relsrc
- Extract the archive to a directory of your choice (e.g. C:\vlink)
- Navigate into that directory and create a new one inside it, named “objects“. This is referenced in the Makefile.Win32 which we’ll be using, but it doesn’t exist yet (at least in the current latest archive when this post was written).
- Now open up the Developer Command Prompt for VS20xx and navigate to where you extracted the vlink archive contents (e.g. “CD \vlink“). Note: if you’re using VS2015 or newer, you will need to modify the Makefile.Win32 file slightly, if you’re on VS2013 no changes are necessary. You can also download the modified Makefile I used with VS2015 for your convenience. The change needed is to remove the “/Dsnprintf=_snprintf” keyword from the COPTS line.
- Type the following command to compile “vlink.exe“:
nmake /f Makefile.Win32 vlink.exe
- After a few seconds, the operation should complete (hopefully without warnings or errors) and you will end up with the executable file, “vlink.exe” in the current directory.
- Move that file together with the VBCC executables we created earlier, in “vbcc\bin“.
VASM
In the next step, we will prepare our Assembler. We can download the latest release from the official site: http://sun.hasenbraten.de/vasm/index.php?view=relsrc
- Extract the archive to a directory of your choice (e.g. C:\vasm)
- Navigate to that directory and edit the file “Makefile.Win32“, removing the “_win32” word from the line “TARGET = _win32“. So for example, instead of this:
TARGET = _win32
it should read:
TARGET =
Alternatively, you can download the already modified Makefile I used and place it in your directory (overwriting the previous one).
- Open up the Developer Command Prompt for VS20xx and navigate to where you extracted the vasm archive contents (e.g. “CD \vasm”).
- Type the following command to compile “vasmm68k_mot.exe” and “vobjdump.exe“:
nmake /f Makefile.Win32 CPU=m68k SYNTAX=mot
- After a few seconds, the files should be compiled and ready. Move the files “vasmm68k_mot.exe” and “vobjdump.exe” into our VBCC\bin directory, where all the other executables are kept as well.
Congratulations, we’ve made it this far! All our executables are now ready to run, we just need to configure some Target platforms and take care of a few more details and we’re done.
Configuration
This is where you need to decide where you want the VBCC installation to reside in. In my example, I chose to leave it at “C:\vbcc” so I don’t have to move anything around, but you can choose to place it anywhere you want. From now on, we will refer to that location as <VBCC> for convenience.
- Create two directories in the <VBCC> directory, named “doc” and “config”. Including the previous “bin” directory which contained the executable files, you should now have the following in <VBCC>:
<VBCC>\bin
<VBCC>\config
<VBCC>\doc
- Setup an environment variable named “VBCC” pointing to the path you placed <VBCC> in. This is easily done through the System Properties window (Control Panel -> System -> Advanced System Properties -> Environment Variables button).
- Edit the PATH environment variable and add “%VBCC%\bin” to it.
Note: the environment variables are not applied in the system on Windows, until the user is logged off and back on. You may want to do that step now. π
Target platforms
Now we need some target platforms for our compiler and a proper configuration for them. We can get the necessary files from the official site: http://sun.hasenbraten.de/vbcc/index.php?view=main
- Get the following files from there:
vbcc_bin_amigaos68k.lha (AmigaOS 2.x/3.x 68020+ binaries)
vbcc_target_m68k-amigaos.lha (Compiler target AmigaOS 2.x/3.x M680x0)
- Extract the vbcc_bin_amigaos68k.lha file somewhere, and copy the contents from its “doc” folder to your <VBCC>\doc.
- Copy the contents of the “config” folder to your <VBCC>\config.
- Rename <VBCC>\config\vc.config to vc.cfg.
- Extract the vbcc_target_m68k-amigaos.lha archive somewhere.
- Copy the “targets” and “config” directories contained in the archive to your <VBCC> directory. You should now have the following directories there:
bin\
config\
doc\
targets\
- If you want to have multiple targets (e.g. OS3.x, OS4, MorphOS, etc.) then you will need to modify the configuration file for each target accordingly. Otherwise, if you will only have one target in your system anyway (like in my example, only AmigaOS3.x), you can edit the configuration file at <VBCC>\config\vc.cfg and replace the following two lines:
-rm=delete quiet %s
-rmv=delete %s
with the following:
-rm=del /Q %s
-rmv=del %s
- Replace the following:
vincludeos3:
with this (replace <VBCC> with your path and notice that the slashes are forward ones, not backslashes):
<VBCC>/targets/m68k-amigaos/include/
- Replace the following:
vlibos3:
with this (replace <VBCC> with your path and notice that the slashes are forward ones, not backslashes):
<VBCC>/targets/m68k-amigaos/lib/
If you are feeling lazy, you can download and use my modified vc_config file instead. π
The added benefit for modifying the default config file as shown above, is that you won’t have to specify the target platform in the command line when compiling something. E.g. instead of “vc +aos68k hello.c” you can type “vc hello.c” directly.
This concludes our installation and configuration steps. We should now be ready to run through a little test program.
Hello World!
Open your favorite Text Editor and type in the following text, exactly as you see it:
#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 -o hello hello.c
Note: If you decided to keep multiple target platforms, and didn’t modify the default configuration file but the one for each target instead, you should this line instead (for AmigaOS3.x):
vc +aos68k -o hello hello.c
If all goes well, this should compile and you will end up with an Amiga executable!
As a next step, you may want to install additional SDKs such as the AmigaOS 3.9 NDK, AmigaOS 4.x SDK, RoadShow SDK and so on. Also, I recommend you add the PosixLib from Aminet in your target “lib” folder, as it provides lots of POSIX functionality (if you need it).
If you install any additional SDK, you will need to add it in the Include path with the relevant command (/I<path to include>) and link to any libraries with the Link command (/L<path to lib>). You can of course consult the manual for more details on the various options available.
Happy programming!
I followed your example and it’s spot on! I am working on making my own tool chain for my own 68020 SBC and am working on implementing my own Standard Library and system and although I have read the manuals I am wondering if there is an option to have the compiler output the C code as comments in the assembly output.
Hi Matt,
Sorry for the late reply, but it looks like this post became a spam magnet and I had to filter out a lot of junk. π
I’m not sure if there’s such an option in the compiler, but you will probably get a more accurate answer (and perhaps, a suggestion) in the VBCC related pages/forums.