libpng on FreeBSD: “ld: invalid BFD target”

Ran into a little problem installing libpng 1.2.8 on FreeBSD 5.4. Running make gives the following:
ld -b +s +h libpng12.sl.0 -o libpng12.sl.0.1.2.8 png.pic.o pngset.pic.o pngget.pic.o pngrutil.pic.o pngtrans.pic.o pngwutil.pic.o pngread.pic.o pngrio.pic.o pngwio.pic.o pngwrite.pic.o pngrtran.pic.o pngwtran.pic.o pngmem.pic.o pngerror.pic.o pngpread.pic.o
ld: invalid BFD target `+s'
*** Error code 1Stop in /usr/src/libpng-1.2.8-config.

I found out that there is a typo in the INSTALL file that tells you to use the wrong makefile. It tells you to cp scripts/makefile.hpgcc makefile when in fact you should cp scripts/makefile.freebsd makefile. Using the correct makefile, of course, make works as expected!

MRTG Error: gd-png: fatal libpng error: Invalid filter type specified

I recently upgraded my MRTG install from v 2.10.13 to 2.11.1, and while the upgrade went fine, I ran into problems running mrtg:
[bash] /usr/local/mrtg-2/bin/mrtg /etc/mrtg/mrtg.cfg
gd-png: fatal libpng error: Invalid filter type specified
gd-png error: setjmp returns error condition
gd-png: fatal libpng error: Invalid filter type specified
gd-png error: setjmp returns error condition
gd-png: fatal libpng error: Invalid filter type specified
gd-png error: setjmp returns error condition
.....

I did a thorough Google search and never found a good answer or fix, except for a patch to the MRTG source code, which I didn’t find satisfactory. So it turns out that it was a problem with the PNG libraries. The machine was running an old Redhat 7.2, and libpng had previously been installed via RPM, with the libpng files from this RPM residing in /usr/lib. Prior to upgrading MRTG I had installed a newer libpng via source, with the new libpng files residing in /usr/local/lib. So the problem was that I had two different versions of libpng installed in different places on the machine, and this was causing the problems. This was easily fixed by creating symbolic links from the old RPM dir (/usr/lib) to the new manually installed dir (/usr/local/lib)
[bash] cd /usr/lib
[bash] mv libpng.a libpng.a.old
[bash] ln -s /usr/local/lib/libpng.a libpng.a
[bash] ln -s /usr/local/lib/libpng.so.3.1.2.8 libpng.so.3
[bash] ln -s /usr/local/lib/libpng.so.3 libpng.so

Once this library hell was fixed, MRTG went back to operating as expected.