[issue26439] ctypes.util.find_library fails ALWAYS when gcc is not used
Michael Felt
report at bugs.python.org
Thu Feb 25 11:08:47 EST 2016
Michael Felt added the comment:
Further testing...
I added an extremely simple hack in util.py so that a archive (AIX library) name got returned.
Also in this case - the print cdll.LoadLibrary("libc.a") fails.
+74 if os.name == "posix" and sys.platform == "darwin":
+75 from ctypes.macholib.dyld import dyld_find as _dyld_find
+76 def find_library(name):
+77 possible = ['lib%s.dylib' % name,
+78 '%s.dylib' % name,
+79 '%s.framework/%s' % (name, name)]
+80 for name in possible:
+81 try:
+82 return _dyld_find(name)
+83 except ValueError:
+84 continue
+85 return None
+86
+87 if os.name == "posix" and sys.platform.startswith("aix"):
+88 def find_library(name):
+89 expr = "lib" + name + ".a"
+90 return expr
+91
+92 elif os.name == "posix":
+93 # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
+94 import re, tempfile, errno
+95
+96 def _findLib_gcc(name):
+275 else:
+276 print cdll.LoadLibrary("libc.a")
+277 print cdll.LoadLibrary("libm.so")
+278 print cdll.LoadLibrary("libcrypt.so")
root at x064:[/tmp]python -m ctypes.util
libm.a
libc.a
libbz2.a
Traceback (most recent call last):
File "/opt/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/opt/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/opt/lib/python2.7/ctypes/util.py", line 282, in <module>
test()
File "/opt/lib/python2.7/ctypes/util.py", line 276, in test
print cdll.LoadLibrary("libc.a")
File "/opt/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/opt/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: 0509-022 Cannot load module /usr/lib/libc.a.
0509-103 The module has an invalid magic number.
So, what needs to be returned so that cdll.LoadLibrary could use that result? (e.g., I know that the default libm.a has no shared members on AIX 5.3 TL7 - but libc.a does (shr.o and more, but not all!).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26439>
_______________________________________
More information about the Python-bugs-list
mailing list