Home CPSC 305

Installing the GBA Development Tools

The GBA cross-compiler we're using was compiled for Linux, so I only have instructions for setting the tools up on your own machine if you're using Linux. Also, the tools will not work on Windows Subsystem for Linux (WSL) because it doesn't support running 32-bit programs.

If you are running native Linux, and want to install the tools locally, you can do so:

  1. Download the Compiler and Tools

    Download the DevKit Advance (project home page). This includes the compiler and tools needed for creating Game Boy Advance games. This can be done with the command:

    wget https://ianfinlayson.net/class/cpsc305/files/devkitadv.tar.bz2

  2. Extract the Compiler and Tools

    Extract the tarball some place with the command:

    tar -xjvf devkitadv.tar.bz2

  3. Download the build script

    The gbacc build script calls the cross-compiler within DevKit Advance and creates an executable GBA ROM. You can grab it with:

    wget https://ianfinlayson.net/class/cpsc305/files/gbacc
    

    Then, open the file in Vim and change the line that beings with KITHOME= such that it refers to the location where you extracted the "devkitadv" directory to.

    Then give the build script executable permission:

    chmod +x gbacc
    
  4. Place this script somewhere in your PATH so you can run it from any directory.

  5. Grab the GBA Patcher (and other things)

    The DevKit Advance does not produce executables that can actually run on the GBA hardware. The .gba files must be patched so that the GBA will recognize them. For that you can grab a utility I wrote to do the patching.

    For our first few programs, you won't need images or sound, but I also wrote a couple programs to facilitate using these in GBA programs. While we're here, you may as well set those up to. All three are available on my Github:

    For each of these, do the following:

    1. Clone the repository
    2. Go into the directory and run the command make
    3. Place the resulting executable program somewhere in your PATH

  6. Compile Hello World

    Now compile this hello.c file.

    To do so, pass the hello.c file to the gbacc build script:

    gbacc hello.c
    

    This should compile it with no output, and produce a file called "program.gba". This is an executable GBA game.

    You can also give it a custom name:

    gbacc hello.c -o hello.gba
    

    NOTE: If you get an error saying something like:

    devkitadv/bin/arm-agb-elf-gcc: cannot execute binary file: Exec format error
    devkitadv/bin/arm-agb-elf-objcopy: cannot execute binary file: Exec format error
    
    Then the problem is that you are running 64-bit Linux and need some 32-bit libraries to be able to run 32-bit executables (which is what the DevKit uses). To fix this run:
    sudo dpkg --add-architecture i386
    sudo apt update
    sudo apt install libc6-i386
    
  7. Install the GBA Emulator

    You will also need a GBA emulator installed. To do this run the command:

    sudo apt install visualboyadvance vbaexpress
  8. Run Hello World

    To run the program, execute the command:

    vba -4 program.gba

    When you run the program, it should look something like this:

    If you see this, then you are ready to start writing GBA games!

Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.