Skip to content

Rust Linker Error MacOS

Vladislav Buinovski edited this page Jan 21, 2025 · 1 revision

Fixing "linking with cc failed: exit status: 1" Error

This error commonly occurs on MacOS systems, particularly on M1 machines, but can also appear on earlier versions of MacOS.

Solution

The issue can be resolved by configuring Rust's linker settings. Create or modify the ~/.cargo/config.toml file with the following content:

[target.x86_64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

This configuration sets up the necessary linker arguments for both Intel (x86_64) and Apple Silicon (aarch64) architectures.

Additional Information