我正在使用PyO3开发一个锈蚀/ python包,在运行maturin develop之后,它在python中运行得很好。我可以将我的生锈代码导入Python并按照我的预期运行我的函数。
不过,我也希望仍然从Rust运行我的代码,所以当我运行cargo run时,我会得到以下错误:
error: linking with `cc` failed: exit status: 1
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)下面是一些简单的说明来复制这一点:
1.设置
# (replace string_sum with the desired package name)
$ mkdir string_sum
$ cd string_sum
$ python -m venv .env
$ source .env/bin/activate
$ pip install maturin2.使用maturin初始化包
maturin init3.添加main.rs文件
fn main() {
println!("Hello, world!");
}4.跑
cargo run发布于 2022-07-14 02:50:25
我发现这个解决方案类似于cargo test,这里报告的错误。
[lib]
name = "lib"
crate-type = ["cdylib", "rlib"]
...
[dependencies.pyo3]
version = "0.16.5"
[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]如果你跑了:
cargo run --no-default-features它按预期工作。
https://stackoverflow.com/questions/72956305
复制相似问题