cxx
cxx copied to clipboard
Calling a C++ library (that includes another library)
I hope I am not posting in the wrong place.
Is is possible to add an example in which one wants to call a C++ class method that, in turn, does some operations from another library (part of the C++ project).
How would the build.rs compile such a complex C++ library? (Provided that is even possible).
My attempt is to let C++ devs feel at home and never cross the bridge.
You can link the external library .
build.rs
fn main() {
...
...
println!("cargo:rustc-link-lib=LIB");
println!("cargo:rustc-link-search=LIB_PATH");
}
example
fn main() {
...
...
println!("cargo:rustc-link-lib=nghttp2");
println!("cargo:rustc-link-search=/usr/lib/");
}
I think build.rs compilation of complex C++ library is tangential to cxx. You'd do that part exactly the same as you would without cxx involved, such as using the cc crate or cmake crate, or a polyglot build system like Bazel.