C
Install
Section titled “Install”Each release
publishes the C library as maplibre-native-c-<preset>.tar.gz, one archive for
each preset. A preset names a platform, an architecture, and a
backend, such as
macos-arm64-metal or linux-gnu-x64-vulkan. OpenGL presets name their context
instead of the backend: egl, wgl, or webgl.
Download the archive for your preset and unpack it. The directory inside,
maplibre-native-c-<preset>, is the install prefix.
With CMake, point maplibre-native-c_DIR at the prefix’s package config, and
link the imported target:
find_package(maplibre-native-c CONFIG REQUIRED)target_link_libraries(app PRIVATE maplibre-native-c::maplibre-native-c)cmake -S . -B build -Dmaplibre-native-c_DIR=<prefix>/lib/cmake/maplibre-native-ccmake --build buildTo link the static library instead, use
maplibre-native-c::maplibre-native-c-static.
With another build system, use pkg-config:
export PKG_CONFIG_PATH=<prefix>/share/pkgconfigcc -std=c23 main.c $(pkg-config --cflags --libs maplibre-native-c) -o mainOn Windows, put <prefix>/bin on PATH, or copy the DLLs in it next to the
executable. On other platforms, the executable finds the library through the
rpath that pkg-config adds.
Package managers
Section titled “Package managers”With xmake 3.1.2 or later, add the distribution repository at a release’s tag:
add_repositories("maplibre https://github.com/maplibre/maplibre-native-ffi-distribution.git v0.202611.0")add_requires("maplibre-native-c 0.202611.0", {configs = {backend = "vulkan"}})
target("app") set_kind("binary") add_files("main.c") add_packages("maplibre-native-c")Leave out backend to use the platform’s default. For musl on Linux, add
libc = "musl" to configs.
Register the distribution repository as a Git registry. vcpkg takes a commit hash as the baseline, not a tag, so look up the commit of the release’s tag:
git ls-remote https://github.com/maplibre/maplibre-native-ffi-distribution 'refs/tags/v0.202611.0^{}'{ "registries": [ { "kind": "git", "repository": "https://github.com/maplibre/maplibre-native-ffi-distribution", "baseline": "<commit>", "packages": ["maplibre-native-c"] } ]}Choose one backend feature, opengl, metal, or vulkan, and link the CMake
target as above:
{ "dependencies": [{ "name": "maplibre-native-c", "features": ["vulkan"] }]}vcpkg also needs a baseline for its default registry. Keep your manifest’s
builtin-baseline, or set "default-registry": null if you take no other vcpkg
packages.
With Conan 2, clone the distribution repository and add it as a local recipe index. Pull the clone to see newer releases.
git clone https://github.com/maplibre/maplibre-native-ffi-distribution.gitconan remote add maplibre-native-ffi ./maplibre-native-ffi-distribution --type=local-recipes-indexconan install --requires="maplibre-native-c/0.202611.0" --build=missing \ -o "maplibre-native-c/*:backend=vulkan" -g CMakeDeps -g CMakeToolchainbackend takes metal, opengl, vulkan, webgpu, or default. For musl on
Linux, add -o "maplibre-native-c/*:libc=musl".
Swift Package Manager
Section titled “Swift Package Manager”For Apple platforms, MaplibreNativeC.xcframework.zip holds the library as the
framework MaplibreNativeC. Add it to a Swift package as a binary target, with
the zip’s checksum from the release’s SHA256SUMS:
.binaryTarget( name: "MaplibreNativeC", url: "https://github.com/maplibre/maplibre-native-ffi/releases/download/v0.202611.0/MaplibreNativeC.xcframework.zip", checksum: "<checksum>")C code includes <MaplibreNativeC/maplibre_native_c.h>.
Gradle
Section titled “Gradle”For Android, native code can link the library from a Kotlin runtime AAR, through Prefab:
android { buildFeatures { prefab = true }}
dependencies { implementation("org.maplibre.nativeffi:maplibre-native-ffi-runtime-opengl-android:0.202611.0")}find_package(maplibre-native-c REQUIRED CONFIG)target_link_libraries(app PRIVATE maplibre-native-c::maplibre-native-c)Android
Section titled “Android”Initialize the library once per process, before you create a runtime, with the
calling thread’s JNI environment and an Android Context:
mln_android_init(jni_env, context, NULL);