cargo-build man page

cargo-build — Compile the current project


cargo build [Options]


Compile a local package and all of its dependencies.

If the --package argument is given, then SPEC is a package id specification which indicates which package should be built. If it is not given, then the current package is built. For more information on SPEC and its format, see the "cargo help pkgid" command.

Compilation can be configured via the use of profiles which are configured in the manifest. The default profile for this command is dev, but passing the --release flag will use the release profile instead.


-h, --help

Print this message.

-p SPEC, --package SPEC ...

Package to build.

-j IN, --jobs IN

Number of parallel jobs, defaults to # of CPUs.


Build only this package's library.

--bin NAME

Build only the specified binary.

--example NAME

Build only the specified example.

--test NAME

Build only the specified test target.

--bench NAME

Build only the specified benchmark target.


Build artifacts in release mode, with optimizations.


Build all available features.

--features FEATURES

Space-separated list of features to also build.


Do not build the default feature.

--target TRIPLE

Build for the target triple.

--manifest-path PATH

Path to the manifest to compile.

-v, --verbose

Use verbose output.

-q, --quiet

No output printed to stdout.

--color WHEN

Coloring: auto, always, never.


Build a local package and all of its dependencies

$ cargo build

Build a package with optimizations

$ cargo build --release

See Also


Referenced By

cargo(1), cargo-bench(1), cargo-clean(1), cargo-doc(1), cargo-package(1), cargo-run(1), cargo-test(1).

May 2016 The Rust package manager Cargo Manual