|
Banjo API 1.1.0-alpha
Low-level C99 game development API
|
Add Banjo to your project via CMake, pkg-config, or hand-rolled compiler flags.
If you integrate Banjo through FetchContent or add_subdirectory, your build is going to compile Banjo as part of your project, so it needs the same system development headers Banjo itself needs (see Prerequisites).
If you integrate via find_package against a pre-installed Banjo, your build does not recompile Banjo; only Banjo's runtime requirements apply.
Quickest and easiest. CMake automatically downloads Banjo during configuration. Ideal for new projects, OSS development, and CI where dependencies should be reproducible.
Requires an internet connection during the first configuration.
Pin GIT_TAG to a release tag rather than a branch so your build is reproducible: main tracks unreleased development and can shift under you. Stable releases are tagged vX.Y.Z, such as v1.0.0; pick the newest from the Releases page. The pre-releases published there, such as v1.0.0-rc.3, are tagged too, to try a version before it is stable.
Embeds Banjo directly into your project's source tree. Useful for tightly coupled projects or when you need fine-grained control over Banjo's build configuration.
You can control Banjo's configuration from your parent project:
When using add_subdirectory, link against the banjo target, or banjo::banjo, which names the same library. banjo::static or banjo::shared also exists, matching the flavour BUILD_SHARED_LIBS selected.
Appropriate when Banjo has been installed system-wide or to a specific prefix. Recommended for production deployments and packaged distributions.
Install Banjo first:
Then in your project:
An installation can hold both library flavours (see Building Banjo). banjo::banjo follows your project's BUILD_SHARED_LIBS: the static library when it is OFF, the shared one when it is ON or unset, falling back to the other flavour when that one is not installed. Link banjo::static or banjo::shared to pick one explicitly:
If Banjo was installed to a non-standard prefix, specify CMAKE_PREFIX_PATH:
What gets installed:
For non-CMake build systems, Banjo provides a pkg-config file (requires installation first).
banjo links -lbanjo, which picks the shared library when one is installed. To link the static library, use banjo-static: it names the archive itself, even when the shared library sits next to it, adds the system libraries it needs (frameworks on macOS; ws2_32, user32, gdi32 on Windows), and defines BANJO_STATIC:
If installed to a non-standard prefix:
If you prefer not to use a build system, link against Banjo manually (after building it via Building Banjo):
Banjo's optional Linux/Windows backends (X11, Wayland, ALSA, MME) are loaded with dlopen / LoadLibrary at runtime: they have no link-time dependency, so you don't pass -lX11, -lwayland-client, -lasound, or -lwinmm. Backends that do need link-time symbols (Win32, Cocoa, CoreAudio, Emscripten) must be re-listed at your application's link line when using the static libbanjo.a, as must ws2_32 on Windows and, on glibc older than 2.34, -ldl.
A minimal test program:
If this compiles and links, your integration is configured correctly. For a functional example with window creation and rendering, see the Examples topic and the example file start.c.