By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,773 Members | 1,838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,773 IT Pros & Developers. It's quick & easy.

undefined symbol: PyObject_GenericGetAttr when trying to embedPython

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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 ):
import distutils.sysconfig
distutils.sysconfig.get_config_var("LINKFORSHARED" )
'-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

Andreas Jung wrote: 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

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.