Skip to content

Fix MSVC resource linking: link compiled resources via .res linker arg (avoid resource.lib)#45

Merged
BenjaminRi merged 3 commits intoBenjaminRi:masterfrom
vlansco:fix-msvc-compilation
Jan 11, 2026
Merged

Fix MSVC resource linking: link compiled resources via .res linker arg (avoid resource.lib)#45
BenjaminRi merged 3 commits intoBenjaminRi:masterfrom
vlansco:fix-msvc-compilation

Conversation

@vlansco
Copy link
Contributor

@vlansco vlansco commented Dec 30, 2025

First of all, thanks a lot for your work and a nice crate!

This PR fixes the Unsupported archive identifier error while building an msvc target:

error: failed to add native library <project_root>\x86_64-pc-windows-msvc\debug\build\<package_name>-cc8df11cd2e2bce3\out\resource.lib: Unsupported archive identifier

Should also close #40 "Failed to add native library after updating to 0.1.25"

Root cause

The rustc is trying to treat ...\out\resource.lib as a native library archive, but the file that rc.exe produces with /fo...resource.lib is not an MSVC .lib archive. Instead, it is a compiled resource blob, typically a .res COFF resource file. When the rustc/linker pipeline tries to load it “as a library”, it fails with: "Unsupported archive identifier".

Fix

  1. compile resource.rcresource.res
  2. pass resource.res to the linker via cargo:rustc-link-arg=...

Note the -arg instead of -lib in linker option.

@Berrysoft
Copy link

I compiled my project successfully with this PR.

@BenjaminRi BenjaminRi merged commit bf54fbf into BenjaminRi:master Jan 11, 2026
4 checks passed
@BenjaminRi
Copy link
Owner

Thank you for your contribution. CI passed and it passed my inspection. This has been released as 0.1.29.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to add native library after updating to 0.1.25

3 participants