Linking to my own library in Rust gcc:Config


#1

In my build.rs file, I placed the following:

extern crate gcc;

fn main() {
    gcc::Config::new().file("src/test.c").compile("libtest.a");
}

and it works well. But now I want to add a couple flags, such as linking to my own library “-lmylib” and maybe “-fPIC”. I can’t seem to figure out how to do that. Any help would be deeply appreciated!


#2

Maybe .flag() ?

gcc::Config::new().file("src/test.c").flag("-lmylib").flag("-fPIC").compile("libtest.a");

Sorry I don’t have a test project or compiler on this machine to check…


#3

There’s also pic() that should deal with -fPIC.


#4

Flag doesn’t seem to do the trick. Is that the only way, do you know?