[pkg-boost-devel] Bug#440087: Compiling a program using boost-python 1.34.1 and python 2.5 gives undefined symbol for Py_InitModule4

Valerio Mariani valerio.mariani at unibas.ch
Wed Aug 29 16:30:18 UTC 2007


Package: libboost-python
Version: 1.34.1

Architecture: amd64


After updating today (29/08/07) in debian unstable, my code using python 
2.5 and libboost-python1.34.1 does not compile.

A check of dpkg's logs shows that both packages were updated today.

 ere is the compilation command and the error:

g++ -o src/gui/app/giplt -Wl,--export-dynamic -Wl,-rpath-link -Xlinker 
/data/Work/Software/iplt/stage/lib -pthread -Wl,--export-dynamic 
-Wl,-rpath-link -Xlinker /data/Work/Software/iplt/stage/lib 
src/gui/app/giplt.o src/gui/app/giplt_status_bar.o 
src/gui/app/python_shell.o src/gui/app/giplt_frame.o 
src/gui/app/procedure_panel.o -Lstage/lib -L/usr/local/lib -lpython2.5 
-lboost_filesystem-gcc41-1_34_1 -lboost_regex-gcc41-1_34_1 -lxerces-c 
-ltiff -lwx_gtk2u_xrc-2.6 -lwx_gtk2u_qa-2.6 -lwx_gtk2u_html-2.6 
-lwx_gtk2u_adv-2.6 -lwx_gtk2u_core-2.6 -lwx_baseu_xml-2.6 
-lwx_baseu_net-2.6 -lwx_baseu-2.6 -liplt -liplt_geom 
-lboost_python-gcc41-1_34_1 -liplt_alg_common -liplt_info -liplt_gui 
-liplt_version -lboost_program_options-gcc41-1_34_1

/usr/lib/gcc/x86_64-linux-gnu/4.1.3/../../../../lib/libboost_python-gcc41-1_34_1.so: 
undefined reference to `Py_InitModule4'

collect2: ld returned 1 exit status

Compiling against pyhton 2.4 (i.e., changing -lpython2.5 to -lpython2.4 
in the compilation command) solves the problem.

Further investigation determines this function of mine to be the source 
of the problem:

..............................

void GipltFrame::RegisterShell()
{
  PyObject* redir_module = Py_InitModule("Shell", pymethods);
  PythonInterpreter::Instance().Run("import Shell\n");
}

..............................

Although the function seems to be correct according to the python 
embedding documentation.
Pymethods are some methods defined in the same file.

An hypotesis on the nature of the bug (might be completely off-target): 
I read on various frums that this error message can appear as a result 
of trying to mix two different version of python in the same system. Is 
it possible that some libraries my code links to are linked to python 
2.4 (namely the boost-python library), while I am trying to link the 
whole program using python 2.5?

       Valerio Mariani



More information about the pkg-boost-devel mailing list