Compiling PHP With “–with-jpeg-dir” Not Working?

Had this strange issue a couple of days ago, where the following compile command didn’t give me the expected results (ability to use imagecreatefromjpeg() function).

./configure --with-gd --with-jpeg-dir=/usr/lib
make
make test

The “make test” yielded the following results.

SKIP gif --> jpeg conversion test [ext/gd/tests/gif2jpg.phpt] reason: jpeg support unavailable
SKIP jpeg <--> png conversion test [ext/gd/tests/jpeg2png.phpt] reason: jpeg support unavailable
SKIP jpeg <--> gd1/gd2 conversion test [ext/gd/tests/jpg2gd.phpt] reason: jpeg support unavailable

Not exactly what I expected, because the libjpeg library existed in /usr/lib/libjpeg.so. Here’s what managed to fix it, running a “make clean” first, and changing the order of the “–with-gd” and “–with-jpeg-dir” parameters.

make clean
./configure --with-jpeg-dir=/usr/lib --with-gd
make
make test

And a make test now passes on the jpeg!

PASS gif --> jpeg conversion test [ext/gd/tests/gif2jpg.phpt]
PASS jpeg <--> png conversion test [ext/gd/tests/jpeg2png.phpt]
PASS jpeg <--> gd1/gd2 conversion test [ext/gd/tests/jpg2gd.phpt]

Tricky bugger this was …