g++ libstdc++ linker question.
F. Heitkamp
heitkamp@ameritech.net
Wed May 2 11:02:00 GMT 2012
On 04/30/12 13:28, Jonathan Wakely wrote:
> On 30 April 2012 13:39, F. Heitkamp wrote:
>> People will tell me to ask on matplotlib list but I believe this a more
>> generic GNU C++ question.
>> I have been trying to run matplotlib that I built from source on my linux
>> from scratch like box.
>>
>> When I try to run an example I get:
>>
>> bash-4.2$ python2.6 matplotlib-ex1.py
>> Traceback (most recent call last):
>> File "matplotlib-ex1.py", line 13, in<module>
>> import matplotlib.pyplot as plt
>> File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 23, in
>> <module>
>> from matplotlib.figure import Figure, figaspect
>> File "/usr/lib/python2.6/site-packages/matplotlib/figure.py", line 16, in
>> <module>
>> import artist
>> File "/usr/lib/python2.6/site-packages/matplotlib/artist.py", line 6, in
>> <module>
>> from transforms import Bbox, IdentityTransform, TransformedBbox,
>> TransformedPath
>> File "/usr/lib/python2.6/site-packages/matplotlib/transforms.py", line 34,
>> in<module>
>> from matplotlib._path import affine_transform
>> ImportError: /usr/lib/python2.6/site-packages/matplotlib/_path.so: undefined
>> symbol:
>> _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_i
>>
>> I see this symbol is in 32 bits libstdc++ library, but does not seem to
>> appear in 64 bits versions.
> Right, the equivalent symbol in the 64-bit lib ends in _l instead of _i
>
>> bash-4.2$ ldd /usr/lib/python2.6/site-packages/matplotlib/_path.so
>> linux-gate.so.1 => (0xffffe000)
>> libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0xf74f7000)
>> libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xf74de000)
>> libpthread.so.0 => /lib/libpthread.so.0 (0xf74c4000)
>> libc.so.6 => /lib/libc.so.6 (0xf7367000)
>> libdl.so.2 => /lib/libdl.so.2 (0xf7362000)
>> libutil.so.1 => /lib/libutil.so.1 (0xf735e000)
>> libm.so.6 => /lib/libm.so.6 (0xf7338000)
>> /lib/ld-linux.so.2 (0xf77d1000)
>>
>> libstdc++ is not shown as being linked with _path.so
>>
>> Any thoughts?
> Is _path.so a 32-bit or 64-bit library? From the missing symbol I'm
> asuming 32-bit.
>
> It would appear it wasn't correctly linked, so its dependency on
> libstdc++.so isn't recorded in the library by a DT_NEEDED entry.
>
> Does it help if you tell the dynamic linker to preload libstdc++.so?
>
> LD_PRELOAD=/usr/lib/libstdc++.so python2.6 matplotlib-ex1.py
The answers to your questions are bellow.
The LD_PRELOAD comand worked (after changing the backend to PyQT4).
bash-4.2$ file /usr/lib/python2.6/site-packages/matplotlib/_path.so
/usr/lib/python2.6/site-packages/matplotlib/_path.so: ELF 32-bit LSB
shared object, Intel 80386, version 1 (GNU/Linux), dynamically linked,
not stripped
bash-4.2$ readelf -d /usr/lib/python2.6/site-packages/matplotlib/_path.so
Dynamic section at offset 0xfb980 contains 26 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library:
[libpython2.6.so.1.0]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x0000000c (INIT) 0x53d18
0x0000000d (FINI) 0xdaba8
0x00000019 (INIT_ARRAY) 0xfc1c8
0x0000001b (INIT_ARRAYSZ) 36 (bytes)
0x00000004 (HASH) 0xd4
0x00000005 (STRTAB) 0x1261c
0x00000006 (SYMTAB) 0x552c
0x0000000a (STRSZ) 142332 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000003 (PLTGOT) 0xfcc88
0x00000002 (PLTRELSZ) 2160 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x534a8
0x00000011 (REL) 0x36d08
0x00000012 (RELSZ) 116640 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x00000016 (TEXTREL) 0x0
0x6ffffffe (VERNEED) 0x36c38
0x6fffffff (VERNEEDNUM) 3
0x6ffffff0 (VERSYM) 0x35218
0x6ffffffa (RELCOUNT) 1709
0x00000000 (NULL) 0x0
bash-4.2$
bash-4.2$ LD_PRELOAD=/lib/libstdc++.so python2.6 matplotlib-ex1.py
Traceback (most recent call last):
File "matplotlib-ex1.py", line 13, in <module>
import matplotlib.pyplot as plt
File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line
95, in <module>
new_figure_manager, draw_if_interactive, _show = pylab_setup()
File
"/usr/lib/python2.6/site-packages/matplotlib/backends/__init__.py", line
25, in pylab_setup
globals(),locals(),[backend_name])
File
"/usr/lib/python2.6/site-packages/matplotlib/backends/backend_wx.py",
line 45, in <module>
raise ImportError(missingwx)
ImportError: Matplotlib backend_wx and backend_wxagg require wxPython >=2.8
More information about the Gcc-help
mailing list