mainmatter / rust-python-interoperability

A self-paced course to write Python extensions in Rust, one exercise at a time.
https://rust-exercises.com/rust-python-interop/
39 stars 3 forks source link

Linker error in exercise 01_setup #6

Open tvijverb opened 4 months ago

tvijverb commented 4 months ago

Hi Luke, Thanks for creating this course, really nice to learn pyo3 concepts like this. I've unfortunately run into an error when compiling the first maturin exercise 01_setup with the wr command.

/usr/bin/ld: cannot find -lpython3.12: No such file or directory
                  collect2: error: ld returned 1 exit status
        error: linking with `cc` failed: exit status: 1

running the troubleshooting command given in the book (cargo run -p "patcher") causes a different error after running wr:

/workspaces/rust-python-interoperability/target/debug/deps/setup-1d6fda427aa90d95: error while loading shared libraries: libpython3.12.so.1.0: cannot open shared object file: No such file or directory
error: test failed, to rerun pass `--lib`

System & OS details: VSCode devcontainer using the following base-image: mcr.microsoft.com/devcontainers/rust:1-1-bookworm

OS: Debian Bookworm
Rust: 1.79.0
Rye: 0.37.0 (default options with `curl -sSf https://rye.astral.sh/get | bash`)
Platform: linux x64

Seems like Rye, Pyo3 and the Rust compiler are not playing nice ;)

tvijverb commented 4 months ago

Renaming libpython3.12.so to libpython3.12.so.1.0 in the target/debug folder fixed the issue for me

LukeMathWalker commented 4 months ago

Renaming libpython3.12.so to libpython3.12.so.1.0 in the target/debug folder fixed the issue for me

That's indeed the issue, I wonder why it's adding that prefix 🤔