Index: Lib/ctypes/util.py =================================================================== --- Lib/ctypes/util.py (revision 85127) +++ Lib/ctypes/util.py (working copy) @@ -1,4 +1,4 @@ -import sys, os +import sys, os, os.path import contextlib # find_library(name) returns the pathname of a library, or None. @@ -90,8 +90,13 @@ expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) fdout, ccout = tempfile.mkstemp() os.close(fdout) + l_flags = '' + ld_libpath = os.getenv('LD_LIBRARY_PATH') + if ld_libpath: + l_flags = ' -L ' + ' -L '.join( + dir for dir in ld_libpath.split(':') if os.path.isdir(dir)) cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit 10; fi;' \ - '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name + '$CC' + l_flags + ' -Wl,-t -o ' + ccout + ' 2>&1 -l' + name try: f = os.popen(cmd) try: