Skip to content
Latchkey

meson compile: Build the Project

meson compile builds a project from a configured build directory, driving the underlying backend for you.

Since Meson 0.54 the recommended build step is meson compile rather than calling ninja, because it works regardless of the backend (Ninja, Visual Studio, Xcode) and reads jobs and verbosity flags consistently.

What it does

meson compile invokes the configured backend to build targets in the build directory named by -C. It accepts -j for parallelism and --verbose to surface the real commands, mapping them onto whatever backend the project uses.

Common usage

Terminal
meson compile -C build                 # build everything
meson compile -C build -j 4            # cap parallel jobs
meson compile -C build my_target       # build a specific target
meson compile -C build --verbose       # show full commands

Options

FlagWhat it does
-C <dir>Build directory to operate in
-j <N>Number of parallel jobs
--verbosePrint the underlying build commands
<target>Build only the named target(s)
--cleanClean before building

In CI

Prefer meson compile -C build over ninja -C build in portable pipelines so the same command works on Windows MSVC runners. For memory-constrained runners, pass -j to cap concurrency exactly as you would with ninja -j. The compiler cache (ccache/sccache) still applies underneath unchanged.

Common errors in CI

"ERROR: Directory 'build' does not seem to be a Meson build directory." means you did not run meson setup first or used the wrong path. "Can only run 'meson compile' after a successful configuration" appears if setup failed; fix the configure error before compiling. A target-not-found message means the name does not match any declared target.

Related guides

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