Accessing dyn modules from embedded python

Martin v. Löwis loewis at informatik.hu-berlin.de
Wed Oct 9 07:32:27 EDT 2002


Max Ischenko <max at malva.com.uaREMOVE.IT> writes:

> ImportError: /usr/lib/python2.2/lib-dynload/struct.so: undefined symbol: PyString_Type

You need to link your application with -Wl,--export-dynamic.

> 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.)?

As the first step, I recomment that you avoid using shared libraries
as extension modules. Rebuild Python, and make everything a static
module in Modules/Setup. All extension modules will then end up in
libpython22.a.

As the next step, I recommend to write a config.c (or copy the one
generated when building Python, adjusting it to your needs). Compile
config.c into your application, and you won't depend on any external
extension module.

This leaves you with the Python modules. For that, I recommend to use
freeze. Invoke freeze on your application, and it will generate a set
of C files. Compile those into your application as well. freeze will
also generate a Makefile (in a subdirectory), which you might find
useful, or which you can ignore.

HTH,
Martin



More information about the Python-list mailing list