Crate gcc [] [src]

A library for build scripts to compile custom C code

This library is intended to be used as a build-dependencies entry in Cargo.toml:

gcc = "0.2"

The purpose of this crate is to provide the utility functions necessary to compile C code into a static archive which is then linked into a Rust crate. The top-level compile_library function serves as a convenience and more advanced configuration is available through the Config builder.

This crate will automatically detect situations such as cross compilation or other environment variables set by Cargo and will build code appropriately.


Use the default configuration:

extern crate gcc;

fn main() {
    gcc::compile_library("libfoo.a", &["src/foo.c"]);

Use more advanced configuration:

extern crate gcc;

fn main() {
                .define("FOO", Some("bar"))



Extra configuration to pass to gcc.



Compile a library from the given set of input C files.