Undefined references to pyo3 structures when building a shared library on Linux? #3733
Replies: 2 comments
-
Sorry for the long delay here. If you're still stuck on this, it might be worth trying to run the compilation with |
Beta Was this translation helpful? Give feedback.
-
Finally got around to testing this, but I can no longer reproduce my original issue. Since my original question, I had cleared my Rust installation and reinstalled it (via rustup). I don't know if this or something else resolved the issue. But I no longer seem to be encountering the issue regardless. Thank you for your time! |
Beta Was this translation helpful? Give feedback.
-
Hello! I'm attempting to build a library that will allow Fortran to call Python through Rust using pyo3. During the build, I encounter a
undefined reference to 'PyExc_BaseException'
along with many otherundefined reference
exceptions. I have built a minimal example of this situation. Due to the Fortran compiling, the project uses CMake and Corrosion to build the Rust pyo3-based library. The build works on macOS, but fails on Linux.The docs troubleshooting notes a similar error, but this is for extension modules explicitly. Due to a
warning: libpython3.11.so.1.0, needed by /...../librust_library.so, not found (try using -rpath or -rpath-link)
message, it seems likely this might be an issue with the paths for the lookup. I had originally included the setting of therpath
to get the build to work on macOS, which worked successfully. Since then, I've tried various ways to set therpath
or other various target linking methods in the CMakeLists.txt to helplibpython
be discovered, however, I've been unsuccessful. I separately built a minimal case of just Rust calling Python still using CMake and Corrosion to perform the build. This works successfully on both macOS and Linux. Though there's a good chance I'm just not setting the pathing correctly during the build, due to the somewhat similar known issue in the troubleshooting docs, I wanted to check here as well that it might not be some other issue.If anyone can clarify my mistake in setting up the correct rpaths for the library, or can point out why this might be a different issue, I would greatly appreciate it! Thank you for your time!
CMakeLists.txt build script:
Build output:
Beta Was this translation helpful? Give feedback.
All reactions