Cross compiling libpng for ARM Linux with Neon and Zlib

libpng is the standard software library for creating .png image files. It can be built for arm with NEON SIMD support. Cross compiling it for ARM is reasonably straight forward. Its only dependency is zlib which configure can have problems finding.

Before building libpng you will first need to compile zlib.

Then download the libpng source from here, un-zip it etc. and then run confgure as follows:

./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 \
   CPPFLAGS="-mfpu=neon -I/path/to/zlib/include/files" LDFLAGS="-L/path/to/zlib/lib/files"  \
   --prefix=/path/to/dir/for/output/files   

In the above command replace:

a.) the path to your zlib include files (probably inside the install directory the the zlib build installed to)
b.) the path to your zlib lib files
c.) The path to the directory into which you want all of the output files installed
d.) change the compiler names (if different from arm-linux-gnueabi-gcc etc.)

Once configure completes you make & install:

make
make install

Now copy the files from the output directory to your ARM device.