Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared object from dependency not found when loading python library #281

Closed
g-bauer opened this issue Mar 9, 2020 · 3 comments
Closed

Comments

@g-bauer
Copy link

g-bauer commented Mar 9, 2020

Hi,

first of all, thank you very much for this project - it's a pleasure to work with.
I encountered a problem that I am not able to solve - I hope this is the right place to formulate this issue.

I am building a python/pyo3 mixed project. One dependency of my crate (ndarray-linalg) uses either a statically or dynamically linked library (netlib-src).
I am having issues using maturin to build my crate with pyO3 bindings that depends on this library.

Mac

On my Mac, I can use maturin to build the project without problems using maturin develop --release when I use the features=["static"] flag in my dependency's Cargo.toml for netlib-src. However, python will not find the shared object when i build netlib-src via a shared library.

Linux

On Linux, both options don't work.
When importing my package in python, I get:

ImportError: liblapacke.so: cannot open shared object file: No such file or directory
liblapacke.so is correctly built and located in /target/release/build/netlib-src-..../out/lib/.

When building a static library, the symbols are not found. The liblapacke.a is correctly build and located in /target/release/build/netlib-src-..../out/lib/ as well.

There are no problems for my rust binary which also depends on these external libraries.
Any help would be appreciated.

@Genarito
Copy link

Genarito commented Dec 8, 2020

Same problem here, my library depends on libgsl.so.23 and libgslcblas.so. I can ommit checking with flag --skip-auditwheel but then I get error when try to use the downloaded version from PyPi

@Genarito
Copy link

Genarito commented Dec 8, 2020

I've solved this problem using auditwheel repair:

  1. I made a custom docker image installing some extra dependencies, in my case GSL:
FROM konstin2/maturin

# Solves CentOS 6 EOL
RUN echo "https://vault.centos.org/6.10/os/x86_64/" > /var/cache/yum/x86_64/6/base/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/extras/x86_64/" > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/updates/x86_64/" > /var/cache/yum/x86_64/6/updates/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/sclo/x86_64/rh" > /var/cache/yum/x86_64/6/centos-sclo-rh/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/sclo/x86_64/sclo" > /var/cache/yum/x86_64/6/centos-sclo-sclo/mirrorlist.txt

# This is the library I need
RUN yum install -y gsl-devel

ENTRYPOINT [""]
  1. Then builds with Maturin: docker run --rm -v $(pwd):/io custom-image maturin build --skip-auditwheel --manylinux=2014

  2. Finally I made a script to repair for all the wheels generated (repair-wheels.sh):

#!/bin/bash
for whl in target/wheels/*.whl; do
    auditwheel repair "$whl" -w ./target/wheels/wheelhouse
done
  1. Repair: docker run --rm -v $(pwd):/io ggca-build ./repair-wheels.sh

But now It's throwing undefined symbol of some functions of GSL I'm using... Maybe it works for you

@konstin
Copy link
Member

konstin commented Feb 23, 2021

I believe the original report is essentially the same as #387. More in general, maturin can't really do much about the linking behaviour of libraries.

@konstin konstin closed this as completed Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants