Frage

Ugh! I have hit one of those errors where I am really clueless. I have built/installed Python (2.7.1) and I've built/installed boost (1.44.0) against that version of python. I don't see any errors in my boost build, everything goes through fine.

When I turn to do my application build that has a lot of boost dependency, where inside my C++ code, I do have a call to Py_Init(...) I am getting the following error:

Linking CXX executable ../../../myapp_exec
../../../../../config/cmake/platforms/../../../../3rdparty/2012/<pack>/rh5_x86_64_gcc-4.1.2/boost-1.44.0/lib/libboost_python-gcc41-1_44.so: undefined reference to `Py_InitModule4' collect2: ld returned 1 exit status
gmake[2]: *** [myapp_exec] Error 1

I googled around but nothin really comes across as a solution. I don't see this issue on Windows. Appreciate if anyone can share their experiences with similar issues on Linux (RHEL5), and how they overcame it. I could try building boost-1.44.0 against older versions of Python (2.6.4 or older).

Thanks in advance, for your time & interest. -T.

War es hilfreich?

Lösung 2

I think I have resolved the issue. It was basically a matter of adding the arguments linkflags="-m64 -Wl,-E" during the boost build. That it appears fixes the issue.

Andere Tipps

why not use the repository and rpm/yum install everything? it looks to me like gcc 4.1.2(2007) might be too old for boost 1.44(2010) and similarly with python. I think moving to a more recent compiler or a linux distro(latest RHEL based linux..i.e RHEL ,CentOs exc..) upgrade is the way to go.

also did you run make check on boost and python to see if they compiled correctly?

Adding -lpython<version> such as -lpython2.7 solves the problem form me.

NOTE: path to libpython<version> such as libpython2.7.so must be specified using -L

so for python2.7 whose library (libpython2.7.so) is installed at /usr/lib would use: -L/usr/lib -lpython2.7 as one of the linking option when compiling program that uses boost

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top