[Python/C++ Question] Embedding Modules in C++

Mike F Winter mfw127 at skorpio.usask.ca
Thu Aug 16 11:55:46 EDT 2001


Duncan Grisby <dgrisby at uk.research.att.com> wrote:
: In article <9let5g$sh9$1 at tribune.usask.ca>,
: Mike F Winter  <mfw127 at skorpio.usask.ca> wrote:

:>While embedding my python code in C++, I can import and access some
:>system modules (string, etc..) fine, but when I try to import the
:>socket library, I get this error:

: [...]
:>ImportError: /usr/lib/python2.1/lib-dynload/_socket.so: undefined symbol:
:>PyEval_SaveThread

: The problem is that the linker has stripped out all the symbols from
: your executable, apart from the ones you actually use. When Python
: dlopen()s _socket.so, it tries to reference a symbol that has been
: stripped. The solution is to tell your linker not to strip the
: symbols. With GNU ld, for example, the option is --export-dynamic.

Thanks.  I solved the problem by linking in the .so's I was using manually, but
this is certainly a nicer solution.




More information about the Python-list mailing list