[Python/C++ Question] Embedding Modules in C++
Duncan Grisby
dgrisby at uk.research.att.com
Thu Aug 16 05:16:38 EDT 2001
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.
Cheers,
Duncan.
--
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --
More information about the Python-list
mailing list