Failing to statically link to external .lib on windows

I am trying to link to a .lib file on Windows.

I have searched for solutions and tried using build.rs and a local .cargo/config but neither work. Here for example is the .cargo/config file:

[target.x86_64-pc-windows-msvc.DebenuPDFLibraryLIB1312]
rustc-link-lib = ["DebenuPDFLibraryLIB1312"]
rustc-link-search = ["C:\\Program Files (x86)\\Debenu\\PDF Library\\LIB"]

The file I'm trying to link against is C:\Program Files (x86)\Debenu\PDF Library\LIB\DebenuPDFLibrary64DLL1312.lib.

The link error I get is : LINK : fatal error LNK1181: cannot open input file 'DebenuPDFLibrary64DLL1312.lib'. This is preceded by the linker's arguments which include the .lib's name but not its path.

It now builds (although I haven't yet tried actually using it).

In Cargo.toml's [package] section I have:

build = "build.rs"
links = "DebenuPDFLibraryLIB1312"

build.rs contains fn main() {} i.e., does nothing.
And .cargo\config contains:

[target.x86_64-pc-windows-msvc.DebenuPDFLibraryLIB1312]
rustc-link-lib = ["DebenuPDFLibraryLIB1312"]
rustc-link-search = ["C:\\Program Files (x86)\\Debenu\\PDF Library\\LIB"]
1 Like