Rust动态库链接的策略
(本文未经许可禁止转载)
使用外部库libloading的策略
[dependencies]
libloading = "0.8"
fn call_dynamic() -> Result< u32, Box< dyn std::error::Error > > {
unsafe {
let lib = libloading::Library::new("/path/to/liblibrary.so")?;
let func: libloading::Symbol u32> = lib.get(b"my_func")?;
Ok(func())
}
}