我正在 Windows 上尝试 Rust。我的代码声明并调用外部库中的函数。
声明是这样的:
#[link(name = "Rvea0326nc-64")]
extern "C" {
fn WeibullSpeedProbability(wa: &f32, wk: &f32, qu: &f32, prob: &f32, theerr: &i32) -> ();
}
Run Code Online (Sandbox Code Playgroud)
(都是 ByRef,因为 DLL 是 Fortran。它是用 Intel 编译器构建的。)
请注意,文件名没有扩展名。该 DLL 位于 Rust 项目的 \target\debug\deps 文件夹中。
根据此处的文档 https://doc.rust-lang.org/std/keyword.extern.html,这应该在 Windows 上导入 DLL,但我收到错误,因此:
error: linking with `link.exe` failed: exit code: 1181
<SNIP>
= note: LINK : fatal error LNK1181: cannot open input file 'Rvea0326nc-64.lib'
Run Code Online (Sandbox Code Playgroud)
果然,如果我找到并复制生成 DLL 的 *.lib 文件,一切都会正常。DLL 显然是无关紧要的。
我尝试在链接名称中明确添加“.dll”,但 Rust 只是抱怨它找不到 Rvea0326nc-64.dll.lib。
文档有误吗?我错过了什么吗?有没有办法让 Rust 与 DLL …