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

Re: Can't build SWIG python bindings

From: Nicholas Riley <njriley_at_uiuc.edu>
Date: 2002-12-10 06:56:34 CET

On Sun, Dec 08, 2002 at 10:51:36PM -0500, Brandon Ehle wrote:
> >>Did you verify that 'make' built the svn_swig_py-1.dylib library? Did
> >>you configure with --with-swig?

This was the first problem - configure only was accepting SWIG 1.3.16,
not 1.3.17 as I was using. Fixed this in the m4 file, did an
autogen/configure/make/make install, and I got further.

> I believe the one in question is this:
> http://fishbowl.digitalbytes.net:81/svn/scripts/redhat8/subversion/svn-py-swig.patch

Thanks! This patch looked like it should resolve the second problem I
ran into - svn_ra.i/svn_ra.c was not including swigutil_py.h (though
it should through its import of svn_types.i). I tried removing the
#ifdefs around the #include in svn_types.i, but the #include was still
not present in the generated svn_ra.c. Finally I included it
explicitly in svn_ra.i in a %{ %} block:

%module _ra
%include typemaps.i

%{
#include "swigutil_py.h"
%}
[...]

which worked for compilation albeit with a warning about a function
definition that appeared harmless. But then I got a link error:

gcc -Wl,-F. -Wl,-flat_namespace,-U,_environ -bundle -framework Python /Users/nicholas/src/svn/obj/subversion/bindings/swig/python/build/temp.darwin-6.2-Power Macintosh-2.2/svn_ra.o -L/usr/local/encap/subversion/lib -L/usr/local/encap/httpd-2.0/lib -L/usr/local/encap/swig-1.3.17/lib -lsvn_ra-1 -lswigpy -o /Users/nicholas/src/svn/obj/subversion/bindings/swig/python/build/lib.darwin-6.2-Power Macintosh-2.2/svn/_ra.so
ld: warning multiple definitions of symbol _BC
/usr/local/fink/lib/libreadline.4.dylib(terminal.so) definition of _BC
/usr/local/fink/lib/libncurses.dylib.5(lib_termcap.o) definition of _BC
ld: warning multiple definitions of symbol _UP
/usr/local/fink/lib/libreadline.4.dylib(terminal.so) definition of _UP
/usr/local/fink/lib/libncurses.dylib.5(lib_termcap.o) definition of _UP
ld: warning multiple definitions of symbol _PC
/usr/local/fink/lib/libreadline.4.dylib(terminal.so) definition of _PC
/usr/local/fink/lib/libncurses.dylib.5(lib_tputs.o) definition of _PC
ld: Undefined symbols:
_acquire_py_lock
_release_py_lock
error: command 'gcc' failed with exit status 1

acquire_py_lock and release_py_lock are, of course, defined in
swigutil_py.c. From your patch it was clear I needed to add
swigutil_py.c to the _ra compile line as well. Compilation worked
fine at that point, but the module was built incorrectly somehow:

% python
Python 2.2.2 (#14, Nov 30 2002, 15:47:39)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ra
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: Loaded module does not contain symbol _init_ra
>>>

The problem appears to be that the symbol is not called _init_ra, but
rather _init__ra:

% file _ra.so
_ra.so: Mach-O bundle ppc
% nm _ra.so | grep init
00004854 t __wrap_svn_ra_dav_init
00004bd8 t __wrap_svn_ra_init_ra_libs
00004980 t __wrap_svn_ra_local_init
00004aac t __wrap_svn_ra_svn_init
         U _apr_initialize
00000f04 T _init__ra

I was able to fix the problem thusly:

% mv _ra.so __ra.so
% python
Python 2.2.2 (#14, Nov 30 2002, 15:47:39)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __ra
>>> dir(__ra)
['SVN_RA_ABI_VERSION', '__doc__', '__file__', '__name__', 'delete_svn_ra_callbacks_t', 'delete_svn_ra_plugin_t', 'delete_svn_ra_reporter_t', 'delete_svn_ra_simple_password_authenticator_t', 'delete_svn_ra_username_authenticator_t', 'new_svn...

But obviously this is not a permanent solution. Any idea where the
extra underscore is coming from?

-- 
=Nicholas Riley <njriley_at_uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
        Pablo Research Group, Department of Computer Science and
  Medical Scholars Program, University of Illinois at Urbana-Champaign
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Dec 10 06:57:15 2002

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