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:

[build-dependencies]
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.

Examples

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() {
    gcc::Config::new()
                .file("src/foo.c")
                .define("FOO", Some("bar"))
                .include("src")
                .compile("libfoo.a");
}

Structs

Config

Extra configuration to pass to gcc.

Functions

compile_library

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