Reputation: 85
Running into error stating:
/usr/bin/ld: cannot find -lnumsolver
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Upon running:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize(Extension("cy_rbisect",
["cy_rbisect.pyx"],
library_dirs=['../clib'],
libraries=['numsolver']))
)
My 'library files' are numsolver.h, numsolver.c, numsolver.o, numsolver.so
with Cython files: cy_rbisect.pxd, cy_rbisect.pyx.
I've already run the export LD_LIBRARY_PATH='/path/to/numsolver.so' so I'm not sure where I'm going wrong here... My code did work previously but then I renamed all the files updated the header/c/pyx/pxd files respectively and re-compiled. It hasn't been working since.
Upvotes: 2
Views: 1961
Reputation: 13570
EDIT
I haven't used cython myself, but I found this: Using Cython To Link Python To A Shared Library
This might help you write your correct setup.py
with your custom shared library. My old answer was targeted for a general solution as to how to compile and link shared libraries.
(old answer)
How are you compiling your library? For the linker to find your library in a non standard path, you have to use -L
option. So the gcc
command should look like this:
gcc <your *.o files> <your other options> -L /path/to/ -lnumsolver
LD_LIBRARY_PATH
must have the directory path of where your library is found. And the filename has to begin with lib. So rename your so file to /path/to/libnumsolver.so
and set LD_LIBRARY_PATH='/path/to/
. This variable should be used when you are trying to execute your code.
Take a look at Shared libraries with GCC on Linux
Upvotes: 1