setup.py ld cannot find library that is present, paths are configured
-
11-12-2019 - |
Question
I am trying to compile a cython interface to a C library using this tutorial: Using C libraries with Cython but when I go for it with:
python2 setup.py build_ext -i
The linker fails to find the library (the library name is libHorde3D
)
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu build/temp.linux-x86_64-2.7/horde3d.o -L/usr/lib -llibHorde3D -lpython2.7 -o /home/kiril/workspace/horde3d_python/cython/horde3d.so
/usr/bin/ld: cannot find -llibHorde3D
That is very peculiar as libHorde3D.so is present in my /usr/lib and in my /opt/lib, the search path for the linker is configured in /etc/ld.conf to look into these directories and I tried setting the search path with the following variables: LD_LIBRARY_PATH, LIBRARY_PATH, LDFLAGS, as well as by passing it straight:
python2 setup.py build_ext -i -L/opt/lib
I did an ldconfig -v
and the library is listed:
/usr/lib:
libHorde3D.so -> libHorde3D.so
/opt/lib:
libHorde3D.so -> libHorde3D.so
For good measure I tried to change the owner to 'root', still nothing.
What is going on here? Especially since i am able to link the library if the linker is called from Code::Blocks(when working on some supplementary C++ code).
Thanks in advance!
Solution
I think you just need to remove the word lib
from your -l
argument, so change it to -lHorde3D