Error with swig: undefined character: _ZN7hosters11hostersLink7getLinkEi

I am trying to make python binding for this library:

http://code.google.com/p/hosterslib/

I am using swig, heres is the code:

%module pyhosters %{ #include "hosters/hosters.hpp" %} %include "hosters/hosters.hpp" 

I launched

swig -C ++ -python -o swig_wrap.cxx swig.i

and compile with

g ++ -O2 -fPIC -shared -o _pyhosters.so swig_wrap.cxx python-config --libs --cflags -lhosters -lcln -lhtmlcxx pkg-config libglog --libs --cflags -I / usr / include / python2.6 -Wall -wextra

But when I run python and import it, I get:

 >>> import pyhosters Traceback (most recent call last): File "<input>", line 1, in <module> File "./pyhosters.py", line 7, in <module> import _pyhosters ImportError: ./_pyhosters.so: undefined symbol: _ZN7hosters11hostersLink7getLinkEi 

How can i solve this?

Thanks.

+4
source share
1 answer

This is a malformed name:

 hosters::hostersLink::getLink(int) 

Make sure you define this feature.

Well, I looked at the 0.6 hosters in detail. Header files declare two getLink methods:

 std::string getLink(void); std::string getLink(int n); 

But the source file declares only the first:

 std::string hostersLink::getLink(void) {return Link;} 

But SWIG creates wrappers for both functions that spin things up. I recommend doing one of two things:

  • Remove the std::string getLink(int n); as undefined.
  • Add definition for std::string getLink(int n) { ... }
+6
source

Source: https://habr.com/ru/post/1305047/


All Articles