FreeBSD: Stuck on libxml2
by Peter Kirn
So, I’m still new to FreeBSD’s ports system. It seems like something that is potentially really powerful, but I’ve got a bit of learning to do.
I had discovered that while I had build PHP with libpng and libjpeg, libjpeg had not built correctly. (I had built libjpeg separately from ports, I believe – it’s been a while since I set this server up so I don’t recall.)
Now, going back in to try to rebuild, in this order:
1. Rebuilt PHP from ports
2. Headed to /usr/ports/lang/php5-extensions and used the very handy UI-based configuration (make config)
3. Tried to rebuild php5-extensions with GD enabled from ports, so that jpeg and png support build with dependencies
The problem: it gets stuck on libxml2, which is a dependency for all of that. Tried portmanager and portmanager -f, which I thought would go through and try to build those dependencies. Same problem. Tried to build libxml2 directly — see below.
And I see from Dr. Google some other folks are stuck on libxml2 builds on x86_64 systems, too, though no clear solution.
I thought that I did want these built as shared libraries, not just static libraries. Maybe the makefile needs some help in ports for 64-bit systems?
Here’s what happens when I try to build libxml2:
===> Building for libxml2-2.7.3 gmake all-recursive gmake[1]: Entering directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3' Making all in include gmake[2]: Entering directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3/include' Making all in libxml gmake[3]: Entering directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3/include/libxml' gmake[3]: Nothing to be done for `all'. gmake[3]: Leaving directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3/include/libxml' gmake[3]: Entering directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3/include' gmake[3]: Nothing to be done for `all-am'. gmake[3]: Leaving directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3/include' gmake[2]: Leaving directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3/include' Making all in . gmake[2]: Entering directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3' /bin/sh ./libtool --tag=CC --mode=link cc -O2 -fno-strict-aliasing -pipe -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -version-info 5:0:0 -L/usr/local/lib -o libxml2.la -rpath /usr/local/lib 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 c14n.lo xmlstring.lo xmlregexp.lo xmlschemas.lo xmlschemastypes.lo xmlunicode.lo xmlreader.lo relaxng.lo dict.lo SAX2.lo xmlwriter.lo legacy.lo chvalid.lo pattern.lo xmlsave.lo xmlmodule.lo schematron.lo -lz -L/usr/local/lib -liconv -lm cc -shared .libs/SAX.o .libs/entities.o .libs/encoding.o .libs/error.o .libs/parserInternals.o .libs/parser.o .libs/tree.o .libs/hash.o .libs/list.o .libs/xmlIO.o .libs/xmlmemory.o .libs/uri.o .libs/valid.o .libs/xlink.o .libs/HTMLparser.o .libs/HTMLtree.o .libs/debugXML.o .libs/xpath.o .libs/xpointer.o .libs/xinclude.o .libs/nanohttp.o .libs/nanoftp.o .libs/DOCBparser.o .libs/catalog.o .libs/globals.o .libs/threads.o .libs/c14n.o .libs/xmlstring.o .libs/xmlregexp.o .libs/xmlschemas.o .libs/xmlschemastypes.o .libs/xmlunicode.o .libs/xmlreader.o .libs/relaxng.o .libs/dict.o .libs/SAX2.o .libs/xmlwriter.o .libs/legacy.o .libs/chvalid.o .libs/pattern.o .libs/xmlsave.o .libs/xmlmodule.o .libs/schematron.o -Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib -L/usr/local/lib -lz /usr/local/lib/libiconv.so -lm -Wl,-soname -Wl,libxml2.so.5 -o .libs/libxml2.so.5 /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libz.a: could not read symbols: Bad value gmake[2]: *** [libxml2.la] Error 1 gmake[2]: Leaving directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/usr/ports/textproc/libxml2/work/libxml2-2.7.3' gmake: *** [all] Error 2 *** Error code 1
Hi Peter,
Please run the following commands and post the results back here:
ls -l /usr/local/lib/libz.* /usr/lib/libz.*
pkg_which -v /usr/local/lib/libz.* /usr/lib/libz.*
file -L /usr/local/lib/libz.* /usr/lib/libz.*
I think the problem might be that the /usr/local/lib/libz.a file is compiled for 32-bit instead of 64-bit. The commands above should tell me that, as well as how it was installed.
Cheers,
Greg
Hi Greg:
Output of libz.* ls:
-r–r–r– 1 root wheel 107242 Nov 26 2008 /usr/lib/libz.a
lrwxrwxrwx 1 root wheel 14 Feb 8 18:06 /usr/lib/libz.so -> /lib/libz.so.3
-rwxr-xr-x 1 root wheel 115268 Feb 17 20:17 /usr/local/lib/libz.a
Output of file:
/usr/local/lib/libz.a: current ar archive
/usr/lib/libz.a: current ar archive
/usr/lib/libz.so: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), stripped
I don’t have pkg_which or pkgdb on this system. How are those typically installed – via portupgrade?
Hi Peter,
Yes, please install portupgrade-devel like so to get the pkg_which tool:
cd /usr/ports/ports-mgmt/portupgrade-devel && make install clean
Also, please post the output of:
uname -a
Once I see the output of pkg_which /usr/local/lib/libz.*, I hope to know what’s going on.
Cheers,
Greg
Oh yeah, entirely forgot to mention uname!
FreeBSD createdigitalmedia.planet.local 6.4-RELEASE FreeBSD 6.4-RELEASE #0: Wed Nov 26 08:37:42 UTC 2008 root@palmer.cse.buffalo.edu:/usr/obj/usr/src/sys/SMP amd64
Unfortunately, I’m subject to the same issue when trying to install portupgrade.
So, if we’re to assume your theory is correct – which is sure what it looks like – what is the presumed fix?
compiling zlib
cc -shared -o ../../.ext/amd64-freebsd6/zlib.so zlib.o -L. -L../.. -L. -rdynamic -Wl,-soname,../../.ext/amd64-freebsd6/zlib.so -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib -lruby18 -lz -lcrypt -lm -rpath=/usr/local/lib -pthread -lc
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
*** Error code 1
Stop in /usr/ports/lang/ruby18/work/ruby-1.8.7-p160/ext/zlib.
*** Error code 1
My next step would be to rename the /usr/local/lib/libz.a file to /usr/local/lib/libz.a.save and then recompile. Give that a try, and let me know what happens.
Cheers,
Greg
So, yep, that works! Now able to successfully install portupgrade, lang/php, and lang/php5-extensions.
However, with GD enabled in php5-extensions, it doesn’t seem I’m installing libjpeg successfully. (also tried installing from graphics/jpeg)
Researching what may be keeping jpeg support from loading.
Here’s phpinfo():
gd
pkg_which for libjpeg:
/usr/local/lib/libjpeg.a: jpeg-6b_7
/usr/local/lib/libjpeg.la: jpeg-6b_7
/usr/local/lib/libjpeg.so: jpeg-6b_7
/usr/local/lib/libjpeg.so.62: ?
/usr/local/lib/libjpeg.so.9: jpeg-6b_7
If you already had graphics/jpeg installed prior to the PHP installation, php5-gd will detect that libjpeg is present and use it. Is your PHP code unable to call the jpeg related functions successfully, even though the libs are installed?