Ctypes can't find libc on Solaris

Skip Montanaro skip at pobox.com
Sun Jan 27 01:15:05 CET 2013


I'm trying to build PyPy on a Solaris 10 system (not supported by the
PyPy gang).  After worming around distutils' inability to use
environment variables to add command line flags to gcc, I'm stuck with
an error trying to locate libc:

[translation:ERROR] Error:
[translation:ERROR]  Traceback (most recent call last):
[translation:ERROR]    File "translate.py", line 269, in main
[translation:ERROR]     default_goal='compile')
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/translator/driver.py", line 790,
in from_targetspec
[translation:ERROR]     spec = target(driver, args)
[translation:ERROR]    File "targetpypystandalone.py", line 152, in target
[translation:ERROR]     enable_allworkingmodules(config)
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/config/pypyoption.py", line 419,
in enable_allworkingmodules
[translation:ERROR]
config.objspace.usemodules.suggest(**dict.fromkeys(modules, True))
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/config/config.py", line 118, in
suggest
[translation:ERROR]     self.suggestoption(name, value)
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/config/config.py", line 122, in
suggestoption
[translation:ERROR]     self.setoption(name, value, "suggested")
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/config/config.py", line 113, in
setoption
[translation:ERROR]     child.setoption(self, value, who)
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/config/config.py", line 311, in
setoption
[translation:ERROR]     self._validator(toplevel)
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/config/pypyoption.py", line 116,
in validator
[translation:ERROR]     __import__(name)
[translation:ERROR]    File
"/var/tmp/pypy-pypy-07e08e9c885c/pypy/rlib/clibffi.py", line 305, in
<module>
[translation:ERROR]     assert libc_name is not None, "Cannot find C
library, ctypes.util.find_library('c') returned None"
[translation:ERROR]  AssertionError: Cannot find C library,
ctypes.util.find_library('c') returned None
[translation] start debugger...

Digging into ctypes/util.py, it became apparent that it can't find
libc on Solaris.  If you run ctypes/util.py as a main program, it
spits out some library info.  On Linux:

% python
Python 2.7.2 (default, Oct 16 2012, 16:54:10)
[GCC 4.4.6 [TWW]] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>>
% python /opt/TWWfsw/python27/lib/python2.7/ctypes/util.py
libm.so.6
libc.so.6
libbz2.so.1
<CDLL 'libm.so', handle 7f6e8a72f000 at 7f6e8a62b710>
<CDLL 'libcrypt.so', handle 8b8fe0 at 7f6e8a62b710>
libcrypt.so.1

On my Mac:

% python ~/src/python/release27-maint/Lib/ctypes/util.py
/usr/lib/libm.dylib
/usr/lib/libc.dylib
/usr/lib/libbz2.dylib
<CDLL 'libm.dylib', handle 8fe46704 at 3efbf0>
<CDLL 'libcrypto.dylib', handle 230520 at 3efbf0>
<CDLL 'libSystem.dylib', handle 8fe46704 at 3efbf0>
<CDLL 'System.framework/System', handle 8fe46704 at 3efbf0>

On Solaris:

% python /opt/TWWfsw/python27/lib/python2.7/ctypes/util.py
None
None
None
<CDLL 'libm.so', handle fed807b8 at 82c320c>
<CDLL 'libcrypt.so', handle feb703a8 at 82c320c>
None

If I can't locate libc (and perhaps some other libraries), I'm not
going to get any further.  Has anyone encountered this problem and
figured out a workaround?

Thanks,

Skip Montanaro



More information about the Python-list mailing list