Build / Cross Compile lighttpd for ARM Linux with pcre
This is a record of how I built lighttpd with pcre for ARM. Most examples of cross compiling lighttpd for ARM do not include pcre, but to get the best out of lighttpd you really do need pcre built in. So we first need to get and cross compile pcre and then lighttpd.
Build pcre for ARM
In this example I assume that you create the build directories in you home directory, e.g. /home/youruser/ , you will need to change this in the following commands to match your actual directory set-up.
cd /home/youruser mkdir buid_pcre cd build_pcre wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz tar -xzf pcre-8.21.tar.gz cd pcre-8.21 ./configure --host=arm-linux-gnueabi CC=arm-linux-gnueabi-gcc \ AR=arm-linux-gnueabi-ar STRIP=arm-linux-gnueabi-strip \ RANLIB=arm-linux-gnueabi-ranlib \ --prefix=/home/youruser/build_lighttpd/build_pcre/_install make make install
This should build pcre and install the output files into the following directory:
/home/youruser/build_lighttpd/build_pcre/_install
Change this path to suit your own needs.
Build lighttpd for ARM
Now that we have build pcre we can build lighttpd as follows, there is a bit of trickery involved for getting it to build with pcre, but happily this article showed me the way (thanks)!
cd /home/youruser mkdir build_lighttpd cd build_lighttpd wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.32.tar.gz tar -zxvf lighttpd-1.4.32.tar.gz cd lighttpd-1.4.32 ./configure -prefix=/home/youruser/build_lighttpd/_install \ -host=arm-linux-gnueabi CC=arm-linux-gnueabi-gcc \ RANLIB=arm-linux-gnueabi-ranlib STRIP=arm-linux-gnueabi-strip\ --enable-shared --without-mysql --without-zlib --without-bzip2 \ --disable-ipv6 \ PCRECONFIG=/home/youruser/build_lighttpd/build_pcre/_install/bin/pcre-config \ PCRE_LIB=/home/youruser/build_lighttpd/build_pcre/_install/lib/libpcre.a \ CFLAGS="$CFLAGS -DHAVE_PCRE_H=1 -DHAVE_LIBPCRE=1 -I/home/youruser/build_lighttpd/build_pcre/_install/include" make make install
Again remember to change: /home/youruser/ in each case.
If the build succeded, all the files that you need to install lighttpd on your target ARM device should be under: /home/youruser/build_lighttpd/_install
Here is an article which talks about how to manually install lighttpd.
But at a very minimum you need to:
(a) Download and edit the config file – lighttpd.conf
(b) Copy the pcre libs to /usr/lib or similar – libpcre.so.0 , libpcre.so.0.0.1
(c) Copy on the lighttpd binary from: /home/youruser/build_lighttpd/_install/sbin
(d) Copy on the lib folder from /home/youruser/build_lighttpd/_install/lib
(e) Run lighttpd specifying the paths to config file and lib folder, for example:
lighttpd -D -f /etc/lighttpd/lighttpd.conf -m /usr/lib
Thanks to the following articles for the build info!
http://fengh2000.blogspot.ie/2009/06/how-to-cross-compile-lighttpd-with-pcre.html
http://stackoverflow.com/questions/12079498/lighttpd-refernces-wrong-lib-location
Hello Kevein,
During building pcre for ARM, after executing ‘make’, I found as follwing error:
“./.libs/libpcre.so: could not read symbols: File in wrong format”
How can I fix it?
Hi,
I wonder at what stage did you hit this error? is it when you try to build lighttpd? It sounds like pcre has been compiled for your host target rather than for your target ARM device, or perhaps lighttpd isn’t being built for ARM but pcre has. Maybe first try to double check the cross-compile options for both builds to make sure that you are targeting ARM and using the correct flavour of gcc etc.
Good Luck!
Kevin.
Hello Kevin,
Thank you for your kind reply.
I met the error when I built “pcre”.
After configuration, I exectued “make”.
Because of the error, I did not try to build “lighttpd”.
Thank you,
Best regards,
Jungwoo(Jason) Ku
Hi, Could you post up your configuration command, maybe we can spot something in it?
Hii
Im also facing the same error when I try to make pcre My configuration commands is as following gave the following
./configure –host=arm-linux-gnueabihf CC=/opt/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-gcc AR=/opt/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-ar STRIP=/opt/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-strip RANLIB=/opt/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-ranlib –prefix=/home/mistral/build_gen_pcre/_install