Building RGBDS from source
RGBDS is open-source, which means you can always compile it yourself, for example if no pre-built solution is available to you, or if you want a specific version.
RGBDS aims to be relatively painless to compile, keeping its dependencies to a minimum:
- A C11-compatible compiler
libpng
(optional, only required for RGBGFX)
Some of the build steps vary between systems, so the instructions provided here are somewhat generic. Windows works largely differently from everything else, so some expertise is expected if attempting this on Windows.
1. Get the source code
You first need to get the source files to be compiled, using one of the methods below.
- Downloading source snapshots
- Using Git
- Pick a release.
- Under the "GitHub links" heading, follow the
release page
link. - Go to "Assets" at the bottom of that page.
- Download any of the last three listed files (
rgbds-<version>.tar.gz
, "Source code (zip
)", or "Source code (tar.gz
)"). - Extract ("unzip") the file.
- Clone the repository.
- Then, run
git checkout <version>
(e.g.git checkout v0.4.1
). - You're set!
2. Build
The following are required to build RGBDS; most of those should already be installed on your system.
make
and/orcmake
, depending on what method you choose below- The
bash
shell - A C compiler, typically
gcc
orclang
bison
(oryacc
/byacc
prior to RGBDS 0.5.0)pkg-config
(unless usingcmake
)
If you are building RGBGFX, the following are also required:
- A C++ compiler, typically
g++
orclang
libpng
's development headers. For Linux users: the package is typically calledlibpng-dev
,libpng-devel
, or sometimes plainlylibpng
. Additionally, a16
or1.6
may be present afterlibpng
(example).
Two build systems are supported: plain old make
, and CMake.
Both can be used on most systems, but Windows users will almost certainly be unable to use make
.
Make sure to run all of the following commands from the root directory of the sources!
That directory should contain a file called Makefile
, another called CMakeLists.txt
, and a few more.
Using Make
Simply run the following two commands:
make
sudo make install
The second command is optional if you don't want to install RGBDS system-wide.
The following variables can be defined to control installation, like so: make Q=
, make install PREFIX=~/.local
PREFIX
: Location where RGBDS will be installed. Defaults to/usr/local
.bindir
: Location where the binaries will be installed. Defaults to${PREFIX}/bin
.mandir
: Location where the manpages will be installed. Defaults to${PREFIX}/share/man
.DESTDIR
: This is prepended to all paths during the installation. It is mainly used for packaging.Q
: Whether to quiet the build or not. To make the build more verbose, clear this variable. Defaults to@
.STRIP
: Whether to strip the installed binaries of debug symbols or not. Defaults to-s
.BINMODE
: Permissions of the installed binaries. Defaults to755
.MANMODE
: Permissions of the installed man pages. Defaults to644
.
Using CMake
Building RGBDS with CMake requires CMake 3.9 or later.
Run CMake on the project:
- CMake 3.13 and later
- CMake 3.12.4 and earlier
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cd ..Build RGBDS:
cmake --build build
You can install RGBDS. You are not required to, you can do whatever with the four binaries in
build/src
at this point.- CMake 3.15 and later
- CMake 3.14 and earlier
sudo cmake --install build
cd build
sudo make install