OpenWrt Forum Archive

Topic: Including jpeg support in libgd

The content of this topic has been archived on 31 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

In order to use a php gallery (spgm) on my wl-500gx, I installed lighttpd with cgi-mod, php5-cgi, php5-mod-gd. PHP things works really fine, but I noticed a weird thing : I was unable to use gd php functions to manipulate jpeg files. I had a look at the libgd et php5 makefiles in the kamikaze repository and found out that they were compiled without support for jpeg files. That's why I decided to include it myself, by changing the following files:

package/libgd/Makefile
-- without-jpeg \
++ with-jpeg=$(STAGING_DIR)/usr \

package/php5/Makefile
-- without-jpeg \
++ with-jpeg-dir="$(STAGING_DIR)/usr"

I then launch the compilation using V=99 make. The target package/libgd-compile fails with the following error message :

...
/home/bdelagoutte/tmp/trunk/openwrt/staging_dir_mipsel/bin/mipsel-linux-uclibc-g
cc -shared  gd.lo gdfx.lo gd_security.lo gd_gd.lo gd_gd2.lo gd_io.lo gd_io_dp.lo
gd_gif_in.lo gd_gif_out.lo gd_io_file.lo gd_io_ss.lo gd_jpeg.lo gd_png.lo gd_ss
.lo gd_topal.lo gd_wbmp.lo gdcache.lo gdfontg.lo gdfontl.lo gdfontmb.lo gdfonts.
lo gdfontt.lo gdft.lo gdhelpers.lo gdkanji.lo gdtables.lo gdxpm.lo wbmp.lo  -Wl,
--rpath -Wl,/usr/lib -Wl,--rpath -Wl,/usr/lib  -L/usr/lib -L/home/bdelagoutte/tm
p/trunk/openwrt/staging_dir_mipsel/usr/lib -L/home/bdelagoutte/tmp/trunk/openwrt
/staging_dir_mipsel/lib /usr/lib/libjpeg.so -lpng12 -lz -lm  -Wl,-rpath -Wl,/usr
/lib -Wl,-soname -Wl,libgd.so.2 -o .libs/libgd.so.2.0.0
/usr/lib/libjpeg.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[6]: *** [libgd.la] Erreur 1

It seems that the build process is trying to link against my local i386 libjpeg.so library. What's wrong with the changes I made ? Can anyone give me a piece of advice about how to solve this ?

Thank you !

Benjamin

OK, I made some tests today, and found out that the LDFLAGS line in build_mipsel/gd-2.0.33/Makefile was wrong:
LDFLAGS = -L/usr/lib -Wl,-rpath,/usr/lib -L/home/bdelagoutte/tmp/trunk/openwrt/staging_dir_mipsel/usr/lib -L/home/bdelagoutte/tmp/trunk/openwrt/staging_dir_mipsel/lib -L/home/bdelagoutte/tmp/trunk/openwrt/staging_dir_mipsel/usr/lib

Notice that the -L/usr/lib is what lets the linking process being made against my local /usr/lib/libjpeg.so instead against $(STAGING_DIR)/usr/lib/libjpeg.so

I manually edited the LDFLAGS line in build_mipsel/gd-2.0.33/Makefile, removed the -L/usr/lib bad switch. Now it compiles.

I can't figure out why this variable isn't overrided by the LDFLAGS environment variable set in package/libgd/Makefile:

$(PKG_BUILD_DIR)/.configured:
        (cd $(PKG_BUILD_DIR); rm -rf config.{cache,status} ; \
                $(TARGET_CONFIGURE_OPTS) \
                CFLAGS="$(TARGET_CFLAGS)" \
                CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
                LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
                LIBPNG12_CONFIG="$(STAGING_DIR)/usr/bin/libpng12-config" \
                ./configure \

...

In fact, those LDFLAGS are added to the LDFLAGS in Makefile but don't replace them !

Where is my problem ?

Once it worked, I installed the created packages on my asus wl-500gx. It *theorically* runs fine, i.e. the php5-mod-gd includes support for jpeg files. In fact it's unusable for what I was planning to do : it takes a long long time to create a thumbnail from a small 5 KB jpeg file... It runs out of time for a 100 KB jpeg file...

Seems like it wasn't a good idea !

Why is jpeg processing so slow on a small mips device ? The first thing is that the CPU only runs at 200 MHz. The second thing may be that the libjpeg is using a lot of floating point operation, which are slowly processed by a integer CPU. Am I right ?

The discussion might have continued from here.