Skip to content
Latchkey

meson compile: Build a Configured Meson Project

meson compile -C <builddir> builds a project that meson setup configured, wrapping the Ninja backend in a backend-agnostic command.

meson compile (Meson 0.54+) is the preferred way to build, replacing a raw ninja -C build. It stays correct even if the backend is not Ninja.

What it does

meson compile invokes the configured backend (Ninja by default) to build the project in the given build directory. It forwards job count and target names, so your CI step does not hard-code the backend.

Common usage

Terminal
meson compile -C build
meson compile -C build -j 8
meson compile -C build mytarget

Options

FlagWhat it does
-C <dir>Build directory to build in
-j <N>Number of parallel jobs
<target>Build only the named target(s)
--verboseShow full compiler command lines
--cleanClean the build directory

In CI

Use meson compile -C build instead of ninja -C build so the step keeps working if the project ever switches backends. Ninja auto-detects cores, so -j is optional; set it to cap parallelism on constrained runners.

Common errors in CI

"ERROR: Directory build is not a Meson build directory." means setup was never run there. "ninja: error: loading 'build.ninja'" surfacing through meson compile means the same: configure first. A compiler error from the backend appears verbatim; rerun with --verbose to see the exact command. "meson: error: unrecognized arguments: compile" means Meson is older than 0.54; use ninja -C build.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →