Setting Up vbcc on macOS

To properly set up vbcc on macOS for compiling Amiga code, you have a couple of primary methods: using an automated script or undertaking a manual compilation and setup process. Both approaches will provide you with the necessary tools: the vbcc compiler, the vasm assembler, and the vlink linker, all configured for the m68k Amiga target.

Automated Script Installation

This is often the most straightforward way, as it handles many of the download, compilation, and setup steps for you. A great script is available on GitHub:

robertkist/vbcc_installer

This script automates downloading vbcc, its dependencies, the Amiga NDK, building them, and organizing them into an `sdk` folder.

Prerequisites

Before running the script, ensure you have the following command-line tools installed. You can install Homebrew from brew.sh.

Installation Steps

  1. Clone the repository:
    git clone https://github.com/robertkist/vbcc_installer.git
  2. Navigate into the cloned directory:
    cd vbcc_installer
  3. Run `make download` to fetch all necessary source files.
  4. Run `make setup`. The script will ask you some questions about the configuration.
  5. The compiled tools and Amiga SDK (NDK) will be placed in an `sdk` subdirectory within the `vbcc_installer` folder.

Post-Compilation Setup

After the script finishes, you need to move the tools to a permanent location and configure your shell environment.

  1. Create a directory in `/opt` and move the generated `sdk` folder into it. This keeps your system tidy.
    sudo mkdir -p /opt/vbcc
    sudo mv sdk /opt/vbcc/
  2. Set the necessary environment variables in your shell's configuration file (e.g., `~/.zshrc` for Zsh or `~/.bash_profile` for Bash).
    # AMIGA SECTION
    export PATH=/opt/vbcc/sdk/vbcc/bin:$PATH
    export VBCC=/opt/vbcc/sdk/vbcc
    export NDK=/opt/vbcc/sdk/NDK_3.9
    # END AMIGA SECTION

    Remember to source your profile (e.g., `source ~/.zshrc`) or open a new terminal window for the changes to take effect.

  3. The assembler included is named `vasmm68k_mot`, but it's often easier to call it as just `vasm`. Create a symbolic link to make this possible system-wide.
    sudo ln -s /opt/vbcc/sdk/vbcc/bin/vasmm68k_mot /usr/local/bin/vasm

Test Your Installation

  1. Create a `hello.c` file with the following content:
    #include <stdio.h>
    

    int main() { puts(“Hello, World from Amiga!\n”); return 0; }

  2. Compile the file. You can test it with the full paths first to ensure everything is in the right place:
    vc -L/opt/vbcc/sdk/NDK_3.9/Include/linker_libs -I/opt/vbcc/sdk/NDK_3.9/Include/include_h +kick13 hello.c -lamiga -lauto -o hello
  3. If your environment variables are set up correctly, this shorter command will also work:
    vc -L$NDK/Include/linker_libs -I$NDK/Include/include_h +kick13 hello.c -lamiga -lauto -o hello

    You can now run the resulting hello executable in an Amiga emulator!