Skip to content

Do not append .lib extension to .res file on cargo:rustc-link-lib=dylib=stuff.res #81488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rodrigocfd opened this issue Jan 28, 2021 · 6 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries

Comments

@rodrigocfd
Copy link

In Windows, when trying to pass a compiled resource script to the linker (I have MSVC build tools properly installed), I'm using the following line in my build.rs:

println!("cargo:rustc-link-lib=dylib=stuff.res");

The problem is that stuff.res is being renamed to stuff.res.lib, and since this file does not exist, the build fails. If I manually rename my file to stuff.res.lib, then it works.

Is it possible to handle this situation, maybe by identifying the provided extension and letting .res to pass?

Note: this feature request originated from here.

@ehuss ehuss transferred this issue from rust-lang/cargo Jan 28, 2021
@ehuss
Copy link
Contributor

ehuss commented Jan 28, 2021

Transferred to rust-lang/rust repository. The naming convention is done by rustc. (Unfortunately I'm not familiar with compiled resource scripts, so I am uncertain on how they should be integrated.)

@petrochenkov
Copy link
Contributor

I think rust-lang/rfcs#2951 (which is an accepted, but not yet implemented RFC) should help with this, through verbatim modifier specifically.

@camelid camelid added the A-linkage Area: linking into static, shared libraries and binaries label Feb 1, 2021
@petrochenkov
Copy link
Contributor

Closing this issue, the verbatim modifier was implemented about 9 months ago, and #81490 tracks its stabilization.

@rodrigocfd
Copy link
Author

@petrochenkov I just tried to link a .res file and it still didn't work.

Build script:

fn main() {
	println!("cargo:rustc-link-lib=dylib=resources/resources.res");
}

Error message:

error: linking with `link.exe` failed: exit code: 1181
  |
  = note: LINK : fatal error LNK1181: cannot open input file 'resources\resources.res.lib'

It's still searching for resources.res.lib, instead of simply using resources.res.

What am I missing?

@petrochenkov
Copy link
Contributor

@rodrigocfd

What am I missing?

The +verbatim modifier, I guess?

println!("cargo:rustc-link-lib=dylib:+verbatim=resources/resources.res");

@rodrigocfd
Copy link
Author

The +verbatim modifier, I guess?

Exactly that. It works now, thank you @petrochenkov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

4 participants