Reputation: 2387
I'm working on a rust/python package using PyO3 and its working great from python after I run maturin develop
. I can import my rust code into Python and run my functions as I expect.
I would also like to still run my code from Rust though, and so when I run cargo run
, I get the following errors:
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)
Here is are some simple instructions to replicate this:
# (replace string_sum with the desired package name)
$ mkdir string_sum
$ cd string_sum
$ python -m venv .env
$ source .env/bin/activate
$ pip install maturin
maturin
maturin init
main.rs
filefn main() {
println!("Hello, world!");
}
cargo run
Upvotes: 0
Views: 752
Reputation: 2387
I found that the solution is similar to the reported error with cargo test
, here:
[lib]
name = "lib"
crate-type = ["cdylib", "rlib"]
...
[dependencies.pyo3]
version = "0.16.5"
[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]
and then if you run:
cargo run --no-default-features
It works as expected
Upvotes: 1