Link with library with custom extension

Hey!

The SDK I'm trying to use with rust provides libraries with an uncommon file extension (.lib). I would like to put something in the build.rs script of the sdk wrapper crate to link this library into the final binary.

Currently I put the below in the .cargo/config.toml in the project that consumes the sdk wrapper. But it doesn't feel like the right place.

[target.thumbv6m-none-eabi]
rustflags = [
    "-C", "linker=arm-none-eabi-gcc",
    '-C', 'link-args=-Wl,-whole-archive',
    '-C', 'link-args=-L/opt/DA145xx_SDK/6.0.22.1401/sdk/platform/system_library/output/Keil_5',
    '-C', 'link-args=-l:da14531.lib',
    '-C', 'link-args=-Wl,-no-whole-archive',
]

The final result I want to pass to GCC is:

 "-Wl,-whole-archive" "-L/opt/DA145xx_SDK/6.0.22.1401/sdk/platform/system_library/output/Keil_5" "-l:da14531.lib" "-Wl,-no-whole-archive"

I tried outputting cargo::rustc-link-lib=static:+whole-archive=:da14531.lib. But then I get error: library name must not be empty

Try +whole-archive,+verbatim=....

Worked like a charm! Thank you!

"cargo::rustc-link-lib=static:+whole-archive,+verbatim=da14531.lib"

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.