Hi,
I want to access WinRT API functions from a Rust program. When I create a simple executable with an extern block, the program compiles and links. As an example, I created this source file as main.rs in my project:
#[link(name="mincore", kind="static")]
extern "system" {
fn RoUninitialize();
}
fn main() {
unsafe {RoUninitialize();}
}
When I now create a library, e.g. define a lib.rs file with
pub mod roapi {
#[link(name="mincore", kind="static")]
extern "system" {
fn RoUninitialize();
}
pub fn uninit() {
unsafe {RoUninitialize();}
}
}
and change my executable to use the library
fn main() {
use mycrate::roapi;
roapi::uninit();
}
I get linker errors complaining about unresolved externals. I can fix this in the executable by adding an extern block here and then the library gets linked, but this feels wrong because it has already been defined in the lib.rs.
My Cargo.toml also has a buildscript which sets the path, and the package section has a
links = "mincore"
field.
Cheers,
Jens