Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use bindgen with pkg-config or similar. #1247

Open
emilio opened this issue Feb 4, 2018 · 1 comment
Open

Document how to use bindgen with pkg-config or similar. #1247

emilio opened this issue Feb 4, 2018 · 1 comment

Comments

@emilio
Copy link
Contributor

emilio commented Feb 4, 2018

It may be useful to see documentation on bindgen being integrated with it, or with stuff that requires altering the include path in bindgen in general.

It'd be a nice addition to the book I think.

@WGH-
Copy link

WGH- commented Feb 8, 2022

This seems to work, though it does feel weird that I have to do this.

    let library = pkg_config::probe_library("foobar")?;
    let bindings = bindgen::Builder::default()
        .clang_args(library.include_paths.iter().map(|path| format!("-I{}", path.to_string_lossy())))
        .header("src/wrapper.h")
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .generate()
        .expect("Unable to generate bindings");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants