Skip to content Skip to sidebar Skip to footer

Python Extension Module With Embedded Python Calls Wrong Library

I've a python extension module (2.7) (produced by swig), that itself links to a library linked to Python 3.33. Even the module is linked to the version 3.33, when it is instantiate

Solution 1:

Under Windows, DLLs (Linux shared objects analogue) must resolve all of their external symbols during the link phase, so during the build of your extension, the extension is implicitly linked w/ python 3.0 DLL and everything is working just fine (w/o seeing MSVC command line, I'm almost sure the extension is linked w/ stub library located under something like c:/python33/libs/python33.lib)

Under Linux on the other hand, shared objects default link regime isn't resolving all the external symbols, hence the LD specification of -lpython will probably resolved during runtime to the loaded shared objects which is 2.7 based ...

So you've 2 options :

  1. Since you got the sources, under Linux you can load libpython33.so via dlopendynamically to avoid this "DLL hell"

  2. static approach, you shall specify the exact location of python3.3 i.e. instead of the "vague" -lpython (which resolved to python2.7) something like /usr/lib/python3.3/libpython33.so

Post a Comment for "Python Extension Module With Embedded Python Calls Wrong Library"