I know that this may be quite a common question, but since I was unable to
find the answer, I ask :
I try to build a Python plugin for an application. The plugin is a shared
library (.so) loaded at runtime by the main program using dlopen. The
plugin is used to interpret Python scripts for the main application.
So I wrote the following Makefile:
OBJECTS = plugin_python.o
INCLUDE = -I./include -I../include -I/usr/include -I/usr/include/python2.0
CC = gcc
FLAGS = $(INCLUDE) -Wall -g -fPIC
all : plugin_python
rm -rf *.o core plugin_python.so.0.1
cp plugin_python.so.0.1 /home/gros/games/share/crossfire/plugins
plugin_python : $(OBJECTS)
$(CC) $(FLAGS) -shared -Wl,-soname,plugin_python.so.0 $(OBJECTS)
../common/libcross.a /usr/lib/python2.0/config/libpython2.0.a -lpthread
-lutil -ldmalloc -o plugin_python.so.0.1
plugin_python.o : plugin_python.c
$(CC) $(FLAGS) -c plugin_python.c
The plugin/application duo works fine, but when I try to run that script
maildb_file = '/tmp/crossfiremail.db'
maildb = shelve.open(maildb_file)
I get the following error:
ImportError: /usr/lib/python2.0/lib-dynload/structmodule.so: undefined
Following my searches, it seems that I need to tell the linker to export
all symbols of the dynamic symbol table, so I tried to add -export-dynamic
(or -E) in the main making line, but it does not work. What should I do ?
Anyone has an idea ?