undefined symbol: PyObject_GenericGetAttr when trying to embedPython

A

Andreas Jung

I am trying to embed Python within a C++ application (Linux, Python2.3.4).
I am using the example from the example from the "Embeding and Extending"
docs.
This works fine importing a simple module without any imports. However when
I add
an "import urllib" inside the Python script to be imported through my C++
application
then the import fails:

Traceback (most recent call last):
File "/home/ajung/sandboxes/HR2/hr2_zope_wrapper/hr2_wrapper.py", line
16, in hr2_wrapper
import urllib
File "/opt/python-2.3.4/lib/python2.3/urllib.py", line 26, in ?
import socket
File "/opt/python-2.3.4/lib/python2.3/socket.py", line 44, in ?
import _socket
ImportError: /opt/python-2.3.4/lib/python2.3/lib-dynload/_socket.so:
undefined symbol: PyObject_GenericGetAttr

Any ideas?

Andreas
 
R

Rick Ratzel

You may have to link your app with some additional flags. You can
use the distutils module to see which ones you need for loading shared
objects (like _socket.so) at runtime. Here is what my Python build for
Linux needs (from http://elmer.sourceforge.net/PyCon04 ):
'-Xlinker -export-dynamic'

Then, simply add -Xlinker -export-dynamic to the link line for the
embedded Python app and the .so modules should have all the proper
symbols resolved. Hope that helps,

-Rick Ratzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top