[xml] Compiliing libxml2/libxslt on macosx 10.1



Hi, 

this is a (mercifully) shortened version of a message that I sent to the
perl xml mailing list earlier this week about how to get libxml2 to
compile on the 10.1 version of macosx (ie Darwin kernel version 5.1, now
that the versioning system has been changed; previous kernel was 1.4).
No-one came forward with a more beautiful method, so you get to see my
know-nothing hack! I hope somebody can make some sense from my nonsense
and abstract out something useful. Maybe even the sledgehammer approach
outlined below will save someone trying to do the same thing a little
frustration. 

Anyway, anyone familiar with this OSX 10.1 will tell you that getting
packages to compile now is a little trickier it was with the 10.0.x
series, but the changes *usually* amount to peppering lightly with...

LDFLAGS "-flat_namespace -undefined suppress"

Of course that prescription should also be taken with a pinch of salt.
(The complications are a result of the fact that the namespace is now
"twolevel" by default.)

Anyway, here's how I attempted to get libxml2 to compile. 

% setenv LDFLAGS "-flat_namespace -undefined suppress"
% ./configure --with-zlib=/usr --prefix=/usr/local -without-iconv
% make
...[output suppressed up to the crucial error]

------------------------------------------------------------------------
gcc -dynamiclib -undefined suppress -o .libs/libxml2.0.0.0.dylib  SAX.lo
entities.lo encoding.lo error.lo parserInternals.lo parser.lo tree.lo
hash.lo list.lo xmlIO.lo xmlmemory.lo uri.lo valid.lo xlink.lo
HTMLparser.lo HTMLtree.lo debugXML.lo xpath.lo xpointer.lo xinclude.lo
nanohttp.lo nanoftp.lo DOCBparser.lo catalog.lo globals.lo threads.lo
-L/usr/lib -lz -lm -lc -install_name  /usr/local/lib/libxml2.0.dylib
-compatibility_version 1 -current_version 1.0
ld: -undefined error must be used when -twolevel_namespace is in effect
/usr/bin/libtool: internal link edit command failed
make[2]: *** [libxml2.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive-am] Error 2
------------------------------------------------------------------------

Gack! It wasn't seeing the "-flat_namespace" flag within this particular
command, and no amount of coaxing and cajoling with compile flags seemed
to alter this one bit. I did notice that cutting and pasting the command
*with* the -flat_namespace added in by hand led to it flashing to
completion. But of course that doesn't help when the command lies
cloaked in the middle of an elaborate Makefile!

OK, enough foreplay, let me cut to the chase: the above was useless, but
a grep in the source directory to find the word "dynamiclib" produced
the key. The *configure* file gives the line that offends OSX's
sensibility so greatly. And here's my sad  workaround, which I hope
triggers something more beautiful in someone's mind; hack the
"-flat_namespace" in there by hand... 

------------------------------------------------------------------------
% diff configure.orig configure
3783c3783
<     archive_cmds='$CC $(test .$module = .yes && echo -bundle || echo
-dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linkopts
-install_name $rpath/$soname $(test -n "$verstring" -a x$verstring !=
x0.0 && echo $verstring)'
---
    archive_cmds='$CC $(test .$module = .yes && echo -bundle || echo
-dynamiclib) $allow_undefined_flag -flat_namespace -o $lib $libobjs
$deplibs$linkopts -install_name $rpath/$soname $(test -n "$verstring" -a
x$verstring != x0.0 && echo $verstring)'
------------------------------------------------------------------------

Patch the configure file as per the above, and "make" runs beautifully.
"make tests" also produces all the right noises: there are a few tests
out of the circa 500 that produce warnings about an external entity not
being found, but even those warnings are predicted by the package.
Nice...

libxslt-1.0.6 also works fine ***with the same modification to the
configure file** and with LDFLAGS as given above. 

Best wishes, and thanks to all those responsible for the great software:
my explorations are only just beginning, but it looks like it's going to
be lots of fun.

Paul



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]