Reputation: 668
I am compiling a pyo3 example code using cargo build. I see this error at the end
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Other codes compile fine. I see this error only when I use pyo3.
I am using MacBook with M1 chip. I have Xcode installed. Rust toolchain stable-aarch64-apple-darwin (default) Python 3.82 (arm64)
This is how I am seeing my dependencies for pyo3
[dependencies.pyo3]
version = "0.14.5"
features = ["extension-module"]
What worked for me
Does anyone else have issues compiling rust with arm Mac?
This is the example code that I am trying https://github.com/bedroombuilds/python2rust/tree/main/15_pymod_in_rust/rust/pyo3_monte_carlo_pi
Upvotes: 2
Views: 2110
Reputation: 668
I managed to solve it by adding this to cargo.toml file
[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",
]
Obtained from the PyO3 docs
Upvotes: 7