[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Proof of concept higher-level python bindings for SoC project

From: David James <james_at_cs.toronto.edu>
Date: 2007-05-02 17:48:26 CEST

On 5/2/07, David Glasser <glasser@mit.edu> wrote:
> On 5/1/07, David Glasser <glasser@mit.edu> wrote:
> > File "/Users/glasser/Projects/Subversion/ctypes-python-bindings/ctypesgen/wrap.py",
> > line 29, in load_library
> > return CDLL(path, mode=mode)
> > File "/opt/local/lib/python2.5/ctypes/__init__.py", line 340, in __init__
> > self._handle = _dlopen(self._name, mode)
> > OSError: dlopen(libapr-1.so, 6): image not found
>
> I got through this one with the attached patch; it now manages to open
> libapr but not libaprutil:
>
> Traceback (most recent call last):
> File "/Users/glasser/Projects/Subversion/ctypes-python-bindings/ctypesgen/wrap.py",
> line 334, in <module>
> main(*sys.argv)
> File "/Users/glasser/Projects/Subversion/ctypes-python-bindings/ctypesgen/wrap.py",
> line 321, in main
> exclude_symbols=options.exclude_symbols)
> File "/Users/glasser/Projects/Subversion/ctypes-python-bindings/ctypesgen/wrap.py",
> line 60, in begin_output
> self.print_preamble()
> File "/Users/glasser/Projects/Subversion/ctypes-python-bindings/ctypesgen/wrap.py",
> line 141, in print_preamble
> lib = load_library(library)
> File "/Users/glasser/Projects/Subversion/ctypes-python-bindings/ctypesgen/wrap.py",
> line 29, in load_library
> return CDLL(path, mode=mode)
> File "/opt/local/lib/python2.5/ctypes/__init__.py", line 340, in __init__
> self._handle = _dlopen(self._name, mode)
> OSError: dlopen(/opt/local/lib/libaprutil-1.dylib, 6): Symbol not
> found: _apr_file_close
> Referenced from: /opt/local/lib/libaprutil-1.dylib
> Expected in: flat namespace

This problem occurred because we opened libapr-1.dylib with the
RTLD_LOCAL flag. The RTLD_LOCAL flag specifies that the library we're
loading in is private, and that its symbols should not be shared with
other libraries. Thus, when we loaded libaprutil-1.dylib, we couldn't
find the symbols from libapr-1. I fixed this in ctypesgen by using the
RTLD_GLOBAL flag, which allows the symbols to be shared.

I've also fixed autogen.py to avoid hardcoding the ".so" extension, so
it should be able to find your libraries on Mac OS X now. Could you
update both the ctypes-python-bindings and the ctypesgen library and
try again?

Thanks for your help!

> In fact this can be reproduced with just:
>
> macbook:~/Projects/Subversion/ctypes-python-bindings glasser$ python2.5
> Python 2.5.1 (r251:54863, May 1 2007, 11:28:08)
> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from _ctypes import dlopen
> >>> dlopen("/opt/local/lib/libapr-1.dylib")
> 4196288
> >>> dlopen("/opt/local/lib/libaprutil-1.dylib")
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> OSError: dlopen(/opt/local/lib/libaprutil-1.dylib, 6): Symbol not
> found: _apr_file_close
> Referenced from: /opt/local/lib/libaprutil-1.dylib
> Expected in: flat namespace

Thanks for the simple recipe -- this helped me diagnose the problem!

You should be able to avoid this problem by passing in the RTLD_GLOBAL
flag to dlopen. See
http://www.open-mpi.org/community/lists/users/2006/09/1846.php

Cheers,

David

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed May 2 17:48:38 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.