[Python-Dev] Linker problems on Linux

Thomas Wouters thomas@xs4all.net
Sat, 15 Jul 2000 20:44:10 +0200


On Sat, Jul 15, 2000 at 07:57:45PM +0200, M.-A. Lemburg wrote:

> I just tried to compile the current CVS version on Linux.
> The compile went fine, but when I started Python, I got:

> 'import site' failed; use -v for traceback
> Python 2.0b1 (#1, Jul 15 2000, 19:22:33)  [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
> Traceback (most recent call last):
>   File "/home/lemburg/bin/pyinteractive.py", line 7, in ?
>     import mx.Tools
>   File "/home/lemburg/projects/mx/Tools/__init__.py", line 24, in ?
>     from Tools import *
>   File "/home/lemburg/projects/mx/Tools/Tools.py", line 10, in ?
>     from mxTools import *
>   File "/home/lemburg/projects/mx/Tools/mxTools/__init__.py", line 1, in ?
>     from mxTools import *
> ImportError: /home/lemburg/projects/mx/Tools/mxTools/mxTools.so: undefined symbol: PyObject_Length

> Why isn't PyObject_Length being exported anymore ??? 

PyObject_Length is changed into a #define, to PyObject_Size. This preserves
the API but not the ABI ;) GCC has a construct to make one function an alias
for another:

PyObject * PyObject_Length() __attribute__((alias("PyObject_Size")));

But this is not likely to work in other compilers, and not on all
architectures to start with. The most portable solution is probably to make
PyObject_Length() a wrapper for PyObject_Size, and hope the compiler knows
how to handle that most efficiently.

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!