Makefile-nolib fails linking with missing libpng symbols
Brought to you by:
glennrp
gcc -o pngcrush pngcrush.o -L/sw/lib -L/usr/lib -lpng -lz -lm Undefined symbols for architecture x86_64: "_png_crc_finish", referenced from: _pngcrush_measure_idat in pngcrush.o "_png_crc_read", referenced from: _pngcrush_measure_idat in pngcrush.o "_png_read_transform_info", referenced from: _main in pngcrush.o "_png_reset_crc", referenced from: _pngcrush_measure_idat in pngcrush.o ld: symbol(s) not found for architecture x86_64
When linking pngcrush, the above symbols are not found. libpng16.dylib is in /sw/lib, and those four symbols are marked as local (non-external) in the library.
Building pngcrush with the bundled zlib and libpng libraries works.
What version of pngcrush are you trying to build?
v1.8.7 using the pngcrush-1.8.7.tar.gz tarball and
make -f Makefile-nolib PNGINC=/sw/include PNGLIB=/sw/lib
, but the undefined symbols error also happens with git HEAD.Last edit: Hanspeter Niederstrasser 2016-10-02
Please try git HEAD (version 1.8.8)
Same error after updating to commit a828b8ea07 (current HEAD) in git:
Make sure you don't have png.h in the directory where you are trying to build the nolib version. You should only have
If you are in a directory that contains the libpng and zlib sources, you can build a "nolib"
version by moving png.h out of the way:
Last edit: Glenn Randers-Pehrson 2016-10-03
Try the GIT HEAD again. I revised Makefile-nolib to temporarily move png.h out of the way,
so you don't have to do it manually as I suggested in the previous comment. Just do
as before.
Last edit: Glenn Randers-Pehrson 2016-10-03
The
mv png.h
commands in Makefile-nolib allowed linking to finish successfully. But it led me try to figure out why internal-png.h was being found because I thought I was making sure that system -Iincludes came before local -Iincludes. The following patch also finishes linking, and there's no need to move files around:We force finding png.h through -I includes instead of through the file system.