Embedded Python 2.1 and AIX

Galen Swint hcsgss at texlife.com
Wed Jul 18 12:10:48 EDT 2001


Hello,
I'm embedding Python 2.1 in an AIX 4.3 library and it's crashing every time the
embedded Python calls for an import of the 'string' or 'math' module. With a
little bit of gdb work I can find that it's crashing with SIGSEGV in the
'initstrop' function (or 'initmath' -- take your pick) when it calls
Py_InitModule4. Apparently, when the library is linked the reference to
Py_InitModule4 is not resolved.
I placed some print statements to print the pointer value of Py_InitModule4 and
its fine the four or five times it's called until the library init calls it.
I have done the import by running the embedded Python on a file with the import
statement on, running the import statement using PyRun_SimpleString, and using
PyImport_ImportModule.
I do call Py_Initialize, and I can execute code like prints and PyDict
functions before the import calls.
Some more info
-Python configured with
    ./configure --with-threads --with-gcc --prefix=/opt/local
(also, it is loading the library from the correct directory
(/opt/local/lib/python2.1/lib-dynload) according to gdb)
- The Makefile for the test program is below
I suspect there is some linker flag omitted or something of that nature
Thanks
Galen Swint


**Makefile**
CC=gcc
PYTHONLIB=/opt/local/lib/python2.1/config
PYTHONINC=/opt/local/include/python2.1

all: libtest.o test.o test
	echo Making all.

libtest.o: libtest.c
	gcc -c -g -DAIX -I$(PYTHONINC) libtest.c

test.o:
	gcc -c -g -DAIX test.c


test: test.o libtest.o
	rm -f test
	$(CC) -o test test.o libtest.o -Wl,-brtl -L$(PYTHONLIB) -lpython2.1
-lpthread -lm




More information about the Python-list mailing list