Cross compiling libjpeg for Linux on ARM

I am taking this opportunity to document a cross compilation procedure for libjpeg targeting ARM Linux mostly so that I won’t have to go searching for it again in the future!

First create a directory and cd to it: 

mkdir libjpeg_build
cd libjpeg_build

Now get the source and un-tar it:

wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar -xzvf jpegsrc.v9.tar.gz

Configure the build, specifying your C compiler and cross compilation host, then make:

./configure --host=arm-xilinx-linux CC=arm-xilinx-linux-gnueabi-gcc
make

Here, I am using the xilinx build of the compiler, hence the reference to xilinx in the host and CC parameters, if I wasn’t using the xilinx tools the above configure command may have looked more like this:

./configure --host=arm-linux CC=arm-linux-gnueabi-gcc

Now make install, specifying a directory for the output:

make install DESTDIR=./_install

If all goes well the output of the build process should be written to the _install directory, copy the .so files to the appropriate directory on your target device (e.g. /usr/local/lib)