Hello everyone,
I’m new to rust but I enjoy it a lot.
I would like to know what is the best way to dynamically link with a C library (.so
).
If I understand correctly, there are two ways:
- From the documentation, I should add a
links
attribute underpackage
in myCargo.toml
and I should create a build scriptbuild.rs
- From what I found on internet, I should use this syntax:
#[link(name = "mylib")]
extern {
fn external_fun();
}
Currently, the first way is not working for me whereas the second works well.
Can you help me to better understand these syntax ?