Page 1 of 1

GD library via MacPorts on OS X

Posted: Wed Jul 21, 2010 4:30 pm
by Andrei Fokau
First of all, there is a need for Troubleshooting section of this forum! :)
--

In order to compile Serpent with GD2 library installed via MacPorts, one needs to add the following lines to Makefile so that GCC can find gd.h file etc.

Code: Select all

CFLAGS  += -I/opt/local/include
LDFLAGS += -L/opt/local/lib
Otherwise, one will see the following errors:

Code: Select all

plotgeometry.c:5:16: error: gd.h: No such file or directory
plotgeometry.c: In function 'PlotGeometry':
plotgeometry.c:28: error: 'gdImagePtr' undeclared (first use in this function)
plotgeometry.c:28: error: (Each undeclared identifier is reported only once
plotgeometry.c:28: error: for each function it appears in.)
plotgeometry.c:28: error: expected ';' before 'im'
plotgeometry.c:29: warning: ISO C90 forbids mixed declarations and code
plotgeometry.c:748: error: 'im' undeclared (first use in this function)
plotgeometry.c:748: warning: implicit declaration of function 'gdImageCreate'
plotgeometry.c:752: warning: implicit declaration of function 'gdImageColorAllocate'
plotgeometry.c:780: warning: implicit declaration of function 'gdImageSetPixel'
plotgeometry.c:801: warning: implicit declaration of function 'gdImagePng'
plotgeometry.c:809: warning: implicit declaration of function 'gdImageDestroy'

Code: Select all

ld: library not found for -lgd
collect2: ld returned 1 exit status
make: *** [sss] Error 1

Re: GD library via MacPorts on OS X

Posted: Wed Jul 21, 2010 7:34 pm
by Jaakko Leppänen
Thank's for the tip. I'll add the options in the Makefile for the next update.

I think the main problem is that the compiler doesn't know where to look for the libraries and include files, and options -I and -L define the paths manually. Basically the paths should be defined by two environment variables, LIBRARY_PATH and C_INCLUDE_PATH, but for some reason these variables are not properly set in some platforms.