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:
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:
Extract the Compiler and Tools
Extract the tarball some place with the command:
tar -xjvf devkitadv.tar.bz2
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:
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
Place this script somewhere in your PATH so you can run it from any directory.
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:
Compile Hello World
Now compile this hello.c file.
To do so, pass the hello.c file to the gbacc build script:
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 errorThen 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
Install the GBA Emulator
You will also need a GBA emulator installed. To do this run the command:
sudo apt install visualboyadvance vbaexpress
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 Attribution-NonCommercial 4.0 International License.