classification
Title: ctypes.util.find_library does not work under Solaris
Type: behavior Stage:
Components: ctypes Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: theller Nosy List: FalkNisius, automatthias, kewang, laca, theller
Priority: normal Keywords: patch

Created on 2009-02-17 08:17 by kewang, last changed 2011-10-21 10:02 by FalkNisius.

Files
File name Uploaded Description Edit
util.diff kewang, 2009-02-18 08:34
util.diff kewang, 2009-02-19 02:48 Fixed the TabError
Messages (5)
msg82303 - (view) Author: Ke Wang (kewang) Date: 2009-02-17 08:17
Under Solaris, find_library can not give the correct path.
Solaris does not have /sbin/ldconfig, so _findLib_gcc is used.

def _findLib_gcc(name):
        expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
        fdout, ccout = tempfile.mkstemp()
        os.close(fdout)
        cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; else CC=cc; fi;' \
              '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name
        try:
            f = os.popen(cmd)
            trace = f.read()
            f.close()
        finally:
            try:
                os.unlink(ccout)
            except OSError, e:
                if e.errno != errno.ENOENT:
                    raise
        res = re.search(expr, trace)
        if not res:
            return None
        return res.group(0)

I executed these code manually, and after ‘trace = f.read()‘, I printed
the content of 'trace', which was just as following:

Undefined			first referenced
 symbol  			    in file
main                                /usr/lib/crt1.o
ld: fatal: symbol referencing errors. No output written to /tmp/tmpYN85Fm
collect2: ld returned 1 exit status
msg82317 - (view) Author: Ke Wang (kewang) Date: 2009-02-17 10:54
I tested the command 'gcc -Wl,-t' on Ubuntu, it works fine.
But on Solaris, it doesn't work as expected.

Finally I find that gcc does not use GNU ld on Solaris, instead, it uses
SUN ld.
msg82412 - (view) Author: Ke Wang (kewang) Date: 2009-02-18 08:34
On Solaris, we can use crle to find system library path.

Attached a patch to get find_library work with Solaris.
msg82449 - (view) Author: Ke Wang (kewang) Date: 2009-02-19 02:48
Above patch failed in a TabError.
Attached a new one.
msg146076 - (view) Author: Falk Nisius (FalkNisius) Date: 2011-10-21 10:02
Under Ubuntu 11.04 is the _findLib_gcc used and not a ldconfig method.

Why should I install a gcc only to find a dynamic library ? It seems not a well design. The usage of ldconfig, what is more natural at a server in the net than a c compiler. Perhaps it can be changed in the next version, because I can see that on other os th ldconfig method would be preferred.

I'm not an python programmer and have not the possibilities to make a regeression test, thats why I can not help.
History
Date User Action Args
2011-10-21 10:02:36FalkNisiussetnosy: + FalkNisius
messages: + msg146076
2011-10-17 08:25:35automatthiassetnosy: + automatthias
2010-08-05 00:46:44terry.reedysetversions: + Python 2.7, - Python 2.6
2009-02-19 02:48:55kewangsetfiles: + util.diff
messages: + msg82449
2009-02-18 21:19:46lacasetnosy: + laca
2009-02-18 08:34:11kewangsetfiles: + util.diff
keywords: + patch
messages: + msg82412
2009-02-17 10:54:30kewangsetmessages: + msg82317
2009-02-17 08:17:14kewangcreate