Fix MSVC resource linking: link compiled resources via .res linker arg (avoid resource.lib)#45
Merged
BenjaminRi merged 3 commits intoBenjaminRi:masterfrom Jan 11, 2026
Conversation
…and cargo:rustc-link-arg instead of cargo:rustc-link-lib=dylib=resource
|
I compiled my project successfully with this PR. |
Owner
|
Thank you for your contribution. CI passed and it passed my inspection. This has been released as 0.1.29. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of all, thanks a lot for your work and a nice crate!
This PR fixes the Unsupported archive identifier error while building an
msvctarget:Should also close #40 "Failed to add native library after updating to 0.1.25"
Root cause
The
rustcis trying to treat...\out\resource.libas a native library archive, but the file thatrc.exeproduces with/fo...resource.libis 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
resource.rc→resource.resresource.resto the linker via cargo:rustc-link-arg=...Note the -arg instead of -lib in linker option.