[redland-dev] Re: Compiling Python binding on OSX
Dave Beckett
dave at dajobe.org
Sat Aug 18 08:55:41 BST 2007
Aurelien Mazurie wrote:
> Hello,
>
>>> I'm trying to compile the Python bindings for librdf on my OSX
>>> box (10.4.10). Is there somebody that tried that already? I get a
>>> linking error but I can't figure out how to correct it (compiling
>>> librdf itself already was a pain due to a bug for the version
>>> detection of flex).
>>
>> Could you say more about that?
>
> Sure; for both raptor and rasql the configure file compares Flex
> versions by creating and comparing an hash value. For a version X.Y.Z
> for example, the hash is X * 10000 + Y * 100 + Z. So the required
> version of Flex, 2.5.19, will gives 20519. Fine. But the problem is that
> my version of Flex, 2.5.4, albeit being newer, will give 20504, which is
> less than the previous value ... So my Flex is considered outdated while
> it's not. I had to modify the configure.ac files in both raptor/ and
> rasqal/ subdirectories to force them to accept it. A solution would be
> to pad the Z part of the version to 2 numbers for example, by appending
> zeroes.
2.5.4 is not newer than 2.5.19 - your flex is too old. The lexers
use configurations that were added in newer flexes and 2.5.31 was
released in April 2003. Really, please upgrade.
The test seems correct to me, the Z is padded to 2 numbers already.
You don't get this issue/check if you just use configure, not autogen.sh
>
>>> What's weird is that the log show no reference to the Python
>>> framework and libraries I have. Maybe it's the problem?
>>
>> Clearly the question is - where did you install redland/raptor/rasqal
>> ? It's not in the default library search path that is used. It's also
>> not in the path that `redland-config --libs` prints. Once you figure
>> out why that's the case, it should work.
>
> Well, I just ran (for redland-1.0.6) 'autogen.sh' then 'configure'
> then 'make', 'make check' and 'make install', without any parameter. So
> I guess the default compilation values are used? I know redland-config
> and roqet, for example, are installed in /usr/local/bin/. Running
> 'redland-config --libs' return "-L/usr/local/lib -lrdf". And the
> /usr/local/lib indeed contains a bunch of librdf.*, librasqal.* and
> libraptor.* files. Looks like everything is there?
so you probably need
export DYLD_LIBRARY_PATH=/usr/local/lib
in the shell so it can be found at runtime, maybe - it's not in
the default search library search paths.
> I'm not expert but it looks like the problem is not accessing the
> previously install librdf library -- it's accessing the Python library.
> The 'undefined symbols' found sounds all related to python, or maybe the
> librdf / python binding. I re-ran the installation process of both
> redland-1.0.6 and redland-bindings-1.0.6. For the bindings I again ran
> './autogen.sh' then './configure --with-python=/sw/bin/python', and once
> in the python/ subdirectory, I tried 'make'. Interestingly the log is
> slightly different, albeit ending the same. Again, here is an excerpt:
>
> Making all in test
> make[1]: Nothing to be done for `all'.
> gcc -DPACKAGE_NAME=\"Redland\ RDF\ Application\ Framework\ bindings\"
> -DPACKAGE_TARNAME=\"redland-bindings\" -DPACKAGE_VERSION=\"1.0.6.1\"
> -DPACKAGE_STRING=\"Redland\ RDF\ Application\ Framework\ bindings\
> 1.0.6.1\" -DPACKAGE_BUGREPORT=\"http://bugs.librdf.org/\"
> -DPACKAGE=\"redland-bindings\" -DVERSION=\"1.0.6.1\" -DSTDC_HEADERS=1
> -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
> -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1
> -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1
> -I. -DREDLAND_POST_I -DREDLAND_DECL_I -DREDLAND_TYPEMAP_I
> -I/usr/local/include -I/usr/local/include -I/usr/local/include
> -I/sw/include/python2.5 -DSWIG_PYTHON_SILENT_MEMLEAK -g -O2
> -I/usr/local/include -I/usr/local/include -I/usr/local/include
> -DSWIG_PYTHON_SILENT_MEMLEAK -g -O2 -fPIC -DPIC ./Redland_wrap.c -c -o
> Redland_wrap.so
> In file included from ./Redland_wrap.c:2521:
> ./redland-post.i: In function 'librdf_python_unicode_to_bytes':
> ./redland-post.i:161: warning: pointer targets in passing argument 2 of
> 'raptor_unicode_char_to_utf8' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_digest_update':
> ./Redland_wrap.c:3017: warning: pointer targets in passing argument 2 of
> 'librdf_digest_update' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_digest_update_string':
> ./Redland_wrap.c:3063: warning: pointer targets in passing argument 2 of
> 'librdf_digest_update_string' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_new_uri':
> ./Redland_wrap.c:3730: warning: pointer targets in passing argument 2 of
> 'librdf_new_uri' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_new_node_from_uri_string':
> ./Redland_wrap.c:4008: warning: pointer targets in passing argument 2 of
> 'librdf_new_node_from_uri_string' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_new_node_from_literal':
> ./Redland_wrap.c:4122: warning: pointer targets in passing argument 2 of
> 'librdf_new_node_from_literal' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_new_node_from_typed_literal':
> ./Redland_wrap.c:4194: warning: pointer targets in passing argument 2 of
> 'librdf_new_node_from_typed_literal' differ in signedness
> ./Redland_wrap.c: In function
> '_wrap_librdf_new_node_from_blank_identifier':
> ./Redland_wrap.c:4280: warning: pointer targets in passing argument 2 of
> 'librdf_new_node_from_blank_identifier' differ in signedness
> ./Redland_wrap.c: In function
> '_wrap_librdf_model_add_typed_literal_statement':
> ./Redland_wrap.c:5662: warning: pointer targets in passing argument 4 of
> 'librdf_model_add_typed_literal_statement' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_parser_parse_string_as_stream':
> ./Redland_wrap.c:7674: warning: pointer targets in passing argument 2 of
> 'librdf_parser_parse_string_as_stream' differ in signedness
> ./Redland_wrap.c: In function
> '_wrap_librdf_parser_parse_string_into_model':
> ./Redland_wrap.c:7739: warning: pointer targets in passing argument 2 of
> 'librdf_parser_parse_string_into_model' differ in signedness
> ./Redland_wrap.c: In function
> '_wrap_librdf_parser_parse_counted_string_as_stream':
> ./Redland_wrap.c:7804: warning: pointer targets in passing argument 2 of
> 'librdf_parser_parse_counted_string_as_stream' differ in signedness
> ./Redland_wrap.c: In function
> '_wrap_librdf_parser_parse_counted_string_into_model':
> ./Redland_wrap.c:7878: warning: pointer targets in passing argument 2 of
> 'librdf_parser_parse_counted_string_into_model' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_parser_guess_name':
> ./Redland_wrap.c:8033: warning: pointer targets in passing argument 2 of
> 'librdf_parser_guess_name' differ in signedness
> ./Redland_wrap.c:8033: warning: pointer targets in passing argument 3 of
> 'librdf_parser_guess_name' differ in signedness
> ./Redland_wrap.c: In function '_wrap_librdf_new_query':
> ./Redland_wrap.c:8235: warning: pointer targets in passing argument 4 of
> 'librdf_new_query' differ in signedness
> gcc -g -O2 -I/usr/local/include -I/usr/local/include
> -I/usr/local/include -DSWIG_PYTHON_SILENT_MEMLEAK -g -O2 -Wl,-F.
> -Wl,-F. -bundle Redland_wrap.so `redland-config --libs` -o Redland.so
> /usr/bin/ld: Undefined symbols:
> _PyArg_ParseTuple
> _PyArg_UnpackTuple
> _PyBool_FromLong
> _PyCObject_FromVoidPtr
> _PyCObject_Import
>
> ... lines cut here ...
That looks like it's missing some extra args like -fPIC -DPIC -shared ?
I'm building against the system python and that uses a 'Framework'.
Fink python uses a 'Bundle'. I don't know what that means, I grabbed
the args I needed out of python's config. Maybe I was missing
something in the configure guesswork.
python_prefix=`$PYTHON -c 'import sys; print sys.prefix' 2>/dev/null`
python_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
PYTHON_INCLUDES="-I${python_prefix}/include/python${PYTHON_VERSION}"
if test "$python_prefix" != "$python_exec_prefix"; then
PYTHON_INCLUDES="$PYTHON_INCLUDES
-I${python_exec_prefix}/include/python${PYTHON_VERSION}"
fi
...
PYTHON_LIB="${python_prefix}/lib/python${PYTHON_VERSION}/site-packages"
...
# Guess PYTHON_LDFLAGS if not passed in
if test `uname` = Darwin; then
PYTHON_LDFLAGS="-Wl,-F. -Wl,-F. -bundle"
if $PYTHON -c 'import sys, string;
sys.exit(string.find(sys.prefix,"Framework")+1)'; then
:
else
PYTHON_LDFLAGS="$PYTHON_LDFLAGS -framework Python"
fi
else
PYTHON_LDFLAGS="-shared"
fi
See? very ugly, maybe I got it wrong and you need to use
configure --with-python-ldflags=-shared
> _raptor_locator_byte
> _raptor_locator_column
> _raptor_locator_file
> _raptor_locator_line
> _raptor_locator_uri
> _raptor_unicode_char_to_utf8
> _raptor_version_decimal
> _raptor_version_major
> _raptor_version_minor
> _raptor_version_release
> _raptor_version_string
> _rasqal_version_decimal
> _rasqal_version_major
> _rasqal_version_minor
> _rasqal_version_release
> _rasqal_version_string
> collect2: ld returned 1 exit status
> make[1]: *** [Redland-stamp] Error 1
> make: *** [all-recursive] Error 1
The shared link should fix these.
Dave
More information about the redland-dev
mailing list