There are two distinct linker paths, the compile time, and the run time.
I find autoconf (configure
) is rarely set up to do the correct thing with alternate library locations, using --with-something=
usually does not generate the correct linker flags (-R
or -Wl,-rpath
). If you only had .a
libraries it would work, but for .so
libraries what you need to specify is the RPATH
:
export PHP_RPATHS=/usr/local/php5/lib
./configure [options as required]
(In many cases just appending LDFLAGS
to the configure
command is used, but PHP's build process is slightly different.)
This effectively adds extra linker search paths to each binary, as if those paths were specified in LD_LIBRARY_PATH
or your default linker config (/etc/ld.so.conf
). This also takes care of adding -L/usr/local/php5/lib
to LDFLAGS
so that the compile-time and run-time use libraries are from the same directory (there's the potential for problems with mismatched versions in different locations, but you don't need to worry here).
Once built, you can check with:
$ objdump -j dynamic -x ./sapi/cli/php | grep RPATH
RPATH /usr/local/php5/lib
$ objdump -j dynamic -x ./libs/libphp5.so | fgrep RPATH
RPATH /usr/local/php5/lib
Running ldd
will also confirm which libraries are loaded from where.
What --with-jpeg-dir
should be really be used for is to point at /usr/local/
or some top-level directory, the directories include/
, lib/
, and possibly others are appended depending on what the compiler/linker needs.
You only need --with-jpeg-dir
if configure
cannot find the installation, configure will automatically find it in /usr/local
and other (possibly platform specific) "standard" places. In your case I think configure
is finding libjpeg in a standard place, and silently disregarding the directive.
(Also, PHP 5.3.13 is no longer current, I suggest 5.3.21, the current version at this time.)
manpreet
Best Answer
2 years ago
I am compiling php 5.3.13 on my server. I want to create an autonome php5 folder. So prefix is:
In this folder I have a lib folder, where I put all lib needed for php to be executed such as:
Even if I compile with
--with-jpeg-dir=/usr/local/php5/lib/
, php binary is still looking for the file in/usr/lib64
.The only solution I found so far is to manually export
LD_LIBRARY_PATH=/usr/local/php5/lib
I would like the same automatically at compile time. Is that possible?