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.
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
- Go the latest release (or pick a specific version)
- Under "Assets" at the bottom, 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 compatible with C++20, typically
g++
orclang++
(and/or a C compiler prior to RGBDS 0.8.0) bison
(oryacc
/byacc
prior to RGBDS 0.5.0)pkg-config
(if you are usingmake
)libpng
's development headers (if you are building RGBGFX), typically calledlibpng-dev
,libpng-devel
, or justlibpng
(a16
or1.6
suffix may also be present)
Two build systems are supported: plain old make
, and CMake.
Both can be used on most systems, but Windows users will almost certainly need to use cmake
.
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