Discussion:
[PHP-INSTALL] Problem with multiple libxml
dan
2010-08-17 20:20:51 UTC
Permalink
Hello,

I'm trying to compile PHP 5.3.3 on a linux system.
I need to compile with libxml and libxslt support.
The libraries I want to use are located under /usr/local/libxml2
To achieve my goal I run configure with :

./configure
--prefix=/usr/local/apache3
--with-apxs2=/usr/local/apache3/bin/apxs
--with-curl
--with-mysql=/usr
--with-pdo-mysql=/usr
--with-libxml-dir=/usr/local/libxml2
--with-xsl=/usr/local/libxml2
--enable-mbstring
--with-mcrypt

After that, I make, and make install, and apache runs fine with php.

MY PROBLEM :
------------
I already have older versions of libxml and libxslt located under /usr/local
When looking at the results of phpinfo(), I can see that those libraries
have been linked to, instead of the newer ones located in
/usr/local/libxml2.

The problem seems to arise somewhere within libtool which is called by the
Makefile, and generates a linker invocation which explicitly references the
old libraries with erroneous full path names
(libexslt.so, libxslt.so and libxml2.so) :

gcc -shared ext/date/.libs/php_date.o
... lots of .o files ...
-Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib
-Wl,--rpath -Wl,/usr/lib/mysql -Wl,--rpath -Wl,/usr/local/libxml2/lib
-L/usr/local/lib -L/usr/lib/mysql -L/usr/local/libxml2/lib
-lcrypt /usr/local/lib/libexslt.so
... lots of other sometimes redundant libraries ...
/usr/local/lib/libxslt.so
/usr/local/lib/libxml2.so
... -Wl,-soname -Wl,libphp5.so -o .libs/libphp5.so

Is there any wizard out there to give me a hint how I could fix that ?

Best Regards,
Dan
Kenneth Svee
2010-08-18 07:36:13 UTC
Permalink
[ dan ]
Post by dan
Hello,
I'm trying to compile PHP 5.3.3 on a linux system. I need to compile
with libxml and libxslt support. The libraries I want to use are
located under /usr/local/libxml2 To achieve my goal I run configure
./configure
--prefix=/usr/local/apache3
--with-apxs2=/usr/local/apache3/bin/apxs
--with-curl
--with-mysql=/usr
--with-pdo-mysql=/usr
--with-libxml-dir=/usr/local/libxml2
--with-xsl=/usr/local/libxml2
--enable-mbstring
--with-mcrypt
After that, I make, and make install, and apache runs fine with php.
------------
I already have older versions of libxml and libxslt located under
/usr/local When looking at the results of phpinfo(), I can see that
those libraries have been linked to, instead of the newer ones
located in /usr/local/libxml2.
The problem seems to arise somewhere within libtool which is called
by the Makefile, and generates a linker invocation which explicitly
references the old libraries with erroneous full path names
gcc -shared ext/date/.libs/php_date.o
... lots of .o files ...
-Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib
-Wl,--rpath -Wl,/usr/lib/mysql -Wl,--rpath -Wl,/usr/local/libxml2/lib
-L/usr/local/lib -L/usr/lib/mysql -L/usr/local/libxml2/lib
-lcrypt /usr/local/lib/libexslt.so
... lots of other sometimes redundant libraries ...
/usr/local/lib/libxslt.so
/usr/local/lib/libxml2.so
... -Wl,-soname -Wl,libphp5.so -o .libs/libphp5.so
Is there any wizard out there to give me a hint how I could fix that ?
Try adding CPPFLAGS and LDFLAGS to your configure command. They should
be able to prepend your path to the RPATH in the binaries, enabling
them to find your binaries before the ones in /usr/local/lib.

Assuming you have the full install of libxml and libxslt, you should
have both a 'lib' and an 'include' directory within your install path
(/usr/local/libxml2), the flags would be added to your command and
would look something like this:

CPPFLAGS="/usr/local/libxml2/include" \
LDFLAGS="-L/usr/local/libxml2/lib -Wl,-rpath,/usr/local/libxml2/lib" \
./configure \
--prefix=/usr/local/apache3 \
--with-apxs2=/usr/local/apache3/bin/apxs \
--with-curl \
--with-mysql=/usr \
--with-pdo-mysql=/usr \
--with-libxml-dir=/usr/local/libxml2 \
--with-xsl=/usr/local/libxml2 \
--enable-mbstring \
--with-mcrypt

You may have to read up on the LDFLAGS and CPPFLAGS to get them right
for your build.

~ksvee
dan
2010-08-19 15:32:01 UTC
Permalink
[~ksvee] [luc]
This mail to share the solution to my problem (see further down).
Post by dan
Hello,
I'm trying to compile PHP 5.3.3 on a linux system. I need to compile
with libxml and libxslt support. The libraries I want to use are
located under /usr/local/libxml2 To achieve my goal I run configure
./configure
--prefix=/usr/local/apache3
--with-apxs2=/usr/local/apache3/bin/apxs
--with-curl
--with-mysql=/usr
--with-pdo-mysql=/usr
--with-libxml-dir=/usr/local/libxml2
--with-xsl=/usr/local/libxml2
--enable-mbstring
--with-mcrypt
After that, I make, and make install, and apache runs fine with php.
------------
I already have older versions of libxml and libxslt located under
/usr/local When looking at the results of phpinfo(), I can see that
those libraries have been linked to, instead of the newer ones
located in /usr/local/libxml2.
The problem seems to arise somewhere within libtool which is called
by the Makefile, and generates a linker invocation which explicitly
references the old libraries with erroneous full path names
gcc -shared ext/date/.libs/php_date.o
... lots of .o files ...
-Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib
-Wl,--rpath -Wl,/usr/lib/mysql -Wl,--rpath -Wl,/usr/local/libxml2/lib
-L/usr/local/lib -L/usr/lib/mysql -L/usr/local/libxml2/lib
-lcrypt /usr/local/lib/libexslt.so
... lots of other sometimes redundant libraries ...
/usr/local/lib/libxslt.so
/usr/local/lib/libxml2.so
... -Wl,-soname -Wl,libphp5.so -o .libs/libphp5.so
Is there any wizard out there to give me a hint how I could fix that ?
Any tries to get proper options or env settings to ./configure failed.
I finally hacked the generated Makefile to carefully prepend every
reference to /usr/local by /usr/local/libxml2 within any include path
and any loader path.

Here the modified lines :

CPPFLAGS = -I/usr/local/libxml2/include
EXTRA_LDFLAGS = -avoid-version -module
-Wl,-R/usr/local/libxml2/lib:/usr/local/lib -L/usr/local/libxml2/lib
-L/usr/local/lib -L/usr/lib/mysql
EXTRA_LDFLAGS_PROGRAM = -Wl,-R/usr/local/libxml2/lib:/usr/local/lib
-L/usr/local/libxml2/lib -L/usr/local/lib -L/usr/lib/mysql
INCLUDES = [...] -I/usr/local/libxml2/include
-I/usr/local/libxml2/include/libxml2 -I/usr/local/include
-I$(top_builddir)/TSRM -I$(top_builddir)/Zend
NATIVE_RPATHS = -Wl,-rpath,/usr/local/libxml2/lib -Wl,-rpath,/usr/local/lib
-Wl,-rpath,/usr/lib/mysql
PHP_LDFLAGS = -Wl,-R/usr/local/libxml2/lib:/usr/local/lib
-L/usr/local/libxml2/lib -L/usr/local/lib -L/usr/lib/mysql
PHP_RPATHS = -R /usr/local/libxml2/lib -R /usr/local/lib -R /usr/lib/mysql

May thanks to Ken and Luc for the help.

Dan.

Loading...