1

I'm attempting to wrap a library that's made available as a dylib with development headers into python for use with an existing application. I've created my .i file, which compiles without issue, however when I attempt to link the ndipy_wrap.o and libndi.dylib files I get a number of warnings about symbols not being found.

Running ld -bundle -flat_namespace -undefined suppress -o _ndipy.so ndipy_wrap.o libndi.4.dylib means I get a clean exit from the linker, though attempting to load the module into python results in:

import ndipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/d5/Projects/ndipy/ndipy.py", line 15, in <module>
    import _ndipy
ImportError: dlopen(/Users/d5/Projects/ndipy/_ndipy.so, 2): Symbol not found: __Z14NDIlib_destroyv
  Referenced from: /Users/d5/Projects/ndipy/_ndipy.so
  Expected in: flat namespace

I'm at a bit of a loss now, and having stared at this for a number of hours I feel I'm not able to see the wood for the trees in my searches.

Many thanks in advance, Dave

Edited to add: the us of -undefined suppress was a suggestion for a similar solution, though I'm currently unable to locate this! Removing this option results in ld: symbol(s) not found for architecture x86_64

  • Why do you use "-undefined suppress" in the link stage? Would a similar error show up if you remove that line? – F Trias May 13 '20 at 20:47
  • 1
    My apologies, I should have included this in the body, while searching for similar situations this was one of the suggestions, removing it results in a number of symbol(s) not found errors – David McCulloch May 13 '20 at 21:06
  • Perhaps libndi.4.dylib relies on other libraries that you are not linking in? – F Trias May 13 '20 at 22:02
  • Unfortunately not, the only symbols listed as not found by LD are those exposed by libndi. running nm on libndi.4.dylib shows those symbols are exported by the library as well. There's been a lot of head scratching over this, I think I'm going to end up building a c++ library that interacts with libndi and abstracts some of the functionality ., then wrap this custom library. It's more work, but I think it will produce more reliable results. – David McCulloch May 14 '20 at 12:35

0 Answers0