I have a C ++ program that I am trying to wrap / convert in Cython. It uses a specific library, which for some reason will not lead to the creation of a working module for import. By the way, there is a working program in C ++. Here is setup.py:
ext_modules = [ Extension( name="libnmfpy", sources=["interface/nmf_lib.pyx"], include_dirs = ["../src/", numpy.get_include()], libraries=["nmf","mpi_cxx","mpi","m"], library_dirs=["../build/Linux/bin.release","/usr/local/lib/","/usr/lib"], language="c++",) ] setup( name = 'libnmfpy', cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules, )
I should mention that it is libnmf, which seems to be causing problems. The first build of libnmf will cause this script to generate this error:
/usr/bin/ld: ../build/Linux/bin.release/libnmf.a(nmf.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC ../build/Linux/bin.release/libnmf.a: could not read symbols: Bad value collect2: error: ld returned 1 exit status
When I rebuild libnmf with -fPIC, setup generates libnmfpy.so, but when I import it into another script, I would get the above undefined character:
Traceback (most recent call last): File "test.py", line 1, in <module> import libnmfpy ImportError: $path/cython/libnmfpy.so: undefined symbol: _ZN4elem6lapack3SVDEiiPdiS1_
If that helped, here is what my search suggested:
nm libnmfpy.so | grep _ZN4elem6lapack3SVDEiiPdiS1_ U _ZN4elem6lapack3SVDEiiPdiS1_ nm ../build/Linux/bin.release/libnmf.a | grep _ZN4elem6lapack3SVDEiiPdiS1_ U _ZN4elem6lapack3SVDEiiPdiS1_
Here is what I think about the cause of the error. I look at what I think is the offensive library libnmf is built on:
nm $another_path/lib/libelemental.a | grep _ZN4elem6lapack3SVDEiiPdiS1_ 0000000000005290 T _ZN4elem6lapack3SVDEiiPdiS1_
I am still not very familiar with libraries and linkers, so any help would be appreciated. Thanks
edit: a little digging made me understand something. Is there a difference between Mac OS X and Linux that I have to keep track of? The people I'm working on wrote this, initially reported build errors like this