Skip to content
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

error: linker clang not found when using windows crate #1268

Closed
4 of 11 tasks
ItsEthra opened this issue May 27, 2023 · 2 comments
Closed
4 of 11 tasks

error: linker clang not found when using windows crate #1268

ItsEthra opened this issue May 27, 2023 · 2 comments

Comments

@ItsEthra
Copy link

Checklist

Describe your issue

Hello, I am trying to cross compile x86_64-pc-windows-gnu from my main arch linux machine x86_64-unknown-linux-gnu. Currently compilation of a binary depended on windows crate does not work, I get this error.

error: linker `clang` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `windows_x86_64_gnu` (build script) due to previous error

My system:

  • cross: 0.2.5
  • cargo: 1.71.0-nightly (09276c703 2023-05-16)
  • rustc: 1.71.0-nightly (9d871b061 2023-05-21)

What target(s) are you cross-compiling for?

x86_64-pc-windows-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

# cargo.toml
[package]
name = "crosswin"
version = "0.1.0"
edition = "2021"

[dependencies]
windows = "0.48.0"
// main.rs
fn main() {}

Additional information / notes

Builds fine without windows crate

@Emilgardis
Copy link
Member

Emilgardis commented May 27, 2023

looks like something needs clang
I can't replicate your issue using the example you've provided, do you maybe have a .cargo/config.toml file with a custom linker set? cc #621

see this wiki entry

@ItsEthra
Copy link
Author

ItsEthra commented May 27, 2023

Hm, the only cargo config I have is in my home folder which has this. Should I create a repo to reproduce the issue? For me it breaks just as I add windows = "0.48.0" to dependencies of a hello world binary.
EDIT: I'm blind, i see clang, imma try without this 🤦
EDIT2: Yea it works

[registries.crates-io]
protocol = "sparse"

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold", "--cfg", "tokio_unstable"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

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

No branches or pull requests

2 participants