Is it possible to re-export an extern "C"
function from another crate so it'll be included in your dynamic library (*.so
or DLL)?
I remember seeing an issue for something like this on the rust-lang/rust
issue tracker but now I can't find it to see what the status is.
Here's a simple example of what I'm talking about.
In crate a
:
#[no_mangle]
pub extern "C" fn add(a: u32, b: u32) -> u32 { ... }
And crate b
:
#![crate-type = "cdylib"]
extern crate a;
pub use a::add; // ensures the *.so contains `add`
You'd then compile crate b
, and when inspecting the symbols which are exported in libb.so
you should see the a::add()
symbol.
$ nm libb.so | grep ' T '
0x12345678 T add