Rust PyO3连接cc失败



我正在使用cargo build编译pyo3示例代码。我在

结尾看到这个错误
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

其他代码编译良好。我只在使用pyo3时看到这个错误。

我用的是带有M1芯片的MacBook。我已经安装了Xcode。Rust工具链stable-aarch64-apple-darwin(默认)Python 3.82 (arm64)

这是我如何看到我的pyo3的依赖

[dependencies.pyo3]
version = "0.14.5"
features = ["extension-module"]

什么对我有用

  1. 将python更改为x86_64, rust工具链更改为x86_64。这工作。

还有谁在arm Mac上编译rust有问题吗?

这是我正在尝试的示例代码https://github.com/bedroombuilds/python2rust/tree/main/15_pymod_in_rust/rust/pyo3_monte_carlo_pi

我设法通过将此添加到货物来解决它。toml文件

[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",
]

https://pyo3.rs/master/building_and_distribution.html

最新更新