About building libpng and linking applications with it

  this page is
 Under Construction

NEW: –lpng Kwiki!

Buildology – What is it?

I have gleaned quite a few little tips and tricks from looking at the build setups done by many packagers who create the installables for a number of projects like Cygwin and Debian GNU/Linux. In the process I've begun to also formulate some opinions about what constitute good build-setup practices. This includes how to use Makefiles and the powers of GNU make to best advantage.

Using make, designing configure scripts, tracking source code changes, setting up a build tree are all aspects of what I term buildology.

View the most recent build activity log now.

It's 91 lines of syntax-highlighted goodness!


Current focus

( view the diff in color here )

WARNING: patch is out of date.

I've created this patch against libpng-1.2.5 which hits two areas:
  1. The makefile for GCC platforms (largely GNU/Linux and Cygwin as well as many others) using the i-x86 hand-coded assembler optimizations (thus, Linux and Cygwin). This makefile is found in the libpng distribution tree by the name scripts/makefile.gcmmx. As a side note: since both Cygwin and GNU/Linux are platforms that support making of symlinks, I find it easiest to just manually symlink a top-level of build tree file Makefile to the needed makefile in scripts/. Then just invoke make in the normal manner.

  2. The libpng-config script which can be installed on the target host system. Its purpose is to make later builds of PNG-using applications against this library easy. By providing correct build-time parameters for the C compiler and the C linker it eliminates guesswork and errors. It is easy to use this utility from makefiles using the idiom found on GNU make: $(shell libpng-config <--paramopt>). It is also easy to use it for larger packages that are configured by employing a more powerful and sophisticated build systemology –– GNU autoconf.

I found some inconsistencies in the libpng-config script (which is generated in the Makefile at build-time, by piecing together template parts, and doing variable interpolation). In particular, one config parameter which is claimed to be valid by $ libpng-config --help instead triggers an error from the script when actually asked for: --ldopts. Fixing this required changing the input template file.


Using libpng (linking apps against it)

Here's a look at the usage dump for libpng-config as I've built it:



More info

Read more about libpng-config here.


Also Might be Helpful:

I have zlib-1.2.1 source for building on gcc for GNU/Linux, with hand-coded assembler built in automatically; both a static .a archive and a Linux .so shared-library are produced.
Check it out. This is a release dated: Mon, 12 Jul 2004 21:18:20 +0000 zlib-1.2.1_somian.tar



Page still Under Construction Mon, 12 Jul 2004 22:15:58 +0000
This document is Copyright (c) 2004 Soren Andersen. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the most recent version of the license may be viewed at

communicate to the author about this document:
perlspinr -AT- att *DOT* net   OR   somian -AT- pobox *DOT* com
use irc: look for somian on #pound-perl.pm (EFNet, freenode, etc.)