Put -lm -lpng at the end of the command line.