This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ctypes.util.find_library(): posix .so without SONAME
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: theller Nosy List: loewis, theller, vstinner
Priority: normal Keywords:

Created on 2008-02-20 00:57 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
libdistorm64.so vstinner, 2008-02-20 10:28 The library compiled on my computer
Messages (7)
msg62580 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-02-20 00:57
ctypes.util.find_library() fails to locate distorm64.so library 
because it has no SONAME entry:

$ objdump -p -j .dynamic /usr/local/lib/libdistorm64.so
/usr/local/lib/libdistorm64.so:     file format elf32-i386
(...)
Dynamic Section:
  NEEDED      libc.so.6
  INIT        0x12f4c
  FINI        0x1bf84
  HASH        0xb4
  (...)

Compare to libm.so:

$ objdump -p -j .dynamic /usr/lib/libm.so
/usr/lib/libm.so:     file format elf32-i386
(...)
Dynamic Section:
  NEEDED      ld-linux.so.2
  NEEDED      libc.so.6
  SONAME      libm.so.6
  INIT        0x335c
  (...)

I don't know why find_library() does use objdump to get SONAME.

Workaround to find_library() "bug": _get_soname() should return 
os.path.basename(f) instead of None. Is it correct?

Note: libdistorm64.so compilation is maybe broken (it's maybe not 
a "real" so library), but I'm able to use it with ctypes :-)
msg62583 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-02-20 04:03
Thomas, can you take a look?
msg62600 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2008-02-20 20:30
Honestly I do not know enough about linux shared libraries to have any
opinion about this issue.  IIRC, the find_library should behave in a
similar way as dynamic linking works on linux.  If this libdistorm64.so
is not a "real" so library, as you write, then maybe it should be
expected that find_library does not find it.

Can someone else help?
msg62601 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-02-20 20:46
haypo, can you please give precise instructions on how to reproduce this
problem?
a) what operating system are you using?
b) what parameters are you passing to find_library?
c) what result are you getting?
d) what result are expecting instead?
msg62605 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-02-20 22:59
« haypo, can you please give precise instructions on how to reproduce 
this problem? »

Sure. Download http://www.ragestorm.net/distorm/dl.php?id=11 
(distorm-pkg1.7.28.tar.bz2), go to build/linux/. Then compile it 
with "make" and install it using make install.

a) what operating system are you using?

I'm using Ubuntu Gutsy, kernel 2.6.22, libc 2.6.1, ld 2.6.1, Python 
2.5.1.

b) what parameters are you passing to find_library?

LIB_FILENAME = find_library('distorm64')

c) what result are you getting?

The function _findLib_ldconfig(), used by find_library() internals, 
returns '/usr/local/lib/libdistorm64.so.1' but _get_soname() returns 
an empty string.

d) what result are expecting instead?

_get_soname(filename) should returns filename instead of None (and not 
basename(filename) as I proposed).

--

libdistorm64.so is not a "real" library, but i'm able to use it with 
cdll.LoadLibrary(). So I think that it can be considered as a Python 
(ctypes) bug.

PS: Why note text box is so small (5 lines) in this bug report???
msg72844 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-09-09 11:28
You can close this issue. It's not really a bug, it's a feature :-) 
find_library() only finds library and not programs. libdistorm64.so is 
compiled as a program, not a library.
msg72847 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2008-09-09 11:30
Cool.
History
Date User Action Args
2022-04-11 14:56:31adminsetgithub: 46398
2008-09-09 11:30:28thellersetstatus: open -> closed
resolution: not a bug
messages: + msg72847
2008-09-09 11:28:44vstinnersetmessages: + msg72844
2008-02-20 22:59:49vstinnersetmessages: + msg62605
2008-02-20 20:46:06loewissetmessages: + msg62601
2008-02-20 20:30:58thellersetmessages: + msg62600
2008-02-20 10:28:03vstinnersetfiles: + libdistorm64.so
2008-02-20 04:03:52loewissetassignee: theller
messages: + msg62583
nosy: + loewis, theller
2008-02-20 00:57:58vstinnercreate