Accessing dyn modules from embedded python
Max Ischenko
max at malva.com.uaREMOVE.IT
Wed Oct 9 03:43:18 EDT 2002
Hi.
I'm trying to embed Python into my application.
The smoke test already works, I've managed to call a pure python function
from my C++ code.
But, an error occurred when I tried this:
# -- my python module used by C++ program --
def translate(data):
return unicode(data, 'koi8-r').encode('cp1251')
$ PYTHONPATH=`pwd` ./translator
Traceback (most recent call last):
File "/home/max/projects/e2u/express2u.py", line 2, in ?
import codecs
File "/usr/lib/python2.2/codecs.py", line 10, in ?
import struct, __builtin__
ImportError: /usr/lib/python2.2/lib-dynload/struct.so: undefined symbol: PyString_Type
Aborted (core dumped)
The translator is build with
PY_CONFIG = /usr/lib/python2.2/config
PY_CFLAGS = -I/usr/include/python2.2/ -g
PY_LDFLAGS = -lpthread -ldl -lutil
translator: translator.cpp TranslationService.o
$(CXX) $(PY_LDFLAGS) -g -o $@ $^ $(PY_CONFIG)/libpython2.2.a
TranslationService.o: TranslationService.cpp TranslationService.h
$(CXX) $(PY_CFLAGS) -Wall -c TranslationService.cpp -o TranslationService.o
Another related question: I want to deploy my C++ app with embedded
Python on machines where no Python is installed. How should bundle other
modules I'm interested in (like locale, codecs, etc.)?
Btw, If I doesn't specify PYTHONPATH the translator can't find the module.
Why is this?
--
In most countries selling harmful things like drugs is punishable.
Then howcome people can sell Microsoft software and go unpunished?
(By hasku at rost.abo.fi, Hasse Skrifvars)
More information about the Python-list
mailing list