Building GD

December 29th, 2004

In attempting to compile gd-2.0.33 on one of my servers, I ran into a make problem. I ran configure just fine with the following options:

./configure –prefix=/usr/local/gd –enable-shared –with-x –with-png=/usr/local/libpng –with-jpeg=/usr/local/libjpeg –with-freetype=/usr/local/freetype

However, when I ran make I got this error:

gd_png.c:15:67: png.h: No such file

This means that even though configure reported finding libpng, make wasn’t linking to it. The solution was simple.

After running configure, edit line 231 of the generated Makefile, which should look like this:

CPPFLAGS = -I/usr/local/freetype/include/freetype2 -I/usr/local/freetype/include -I/usr/local/freetype/include -I/usr/local/libjpeg/include

You simply need to append it with the location of libpng’s include directory:

CPPFLAGS = -I/usr/local/freetype/include/freetype2 -I/usr/local/freetype/include -I/usr/local/freetype/include -I/usr/local/libjpeg/include -I/usr/local/libpng/include

Then run make and make install and you should be set.