一、编译安装GD库时出现的错误
报错信息如下:
gd_png.c:603: error: ‘PNG_COMPRESSION_TYPE_DEFAULT’ undeclared (first use in this function) gd_png.c:
609: error: ‘PNG_COLOR_TYPE_RGB’ undeclared (first use in this function) gd_png.c
725: error: ‘row_pointers’ undeclared (first use in this function) gd_png.c
解决办法:
进入gd源代码目录:/opt/ws/gd2
vim gd_png.c
将16行的png.h修改成 libpng安装目录/include/png.h(/opt/ws/libpng/include/png.h)
make && make install
二、报错信息如下:
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putc’:
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c:51: error: ‘struct gdIOCtx’ has no member named ‘data’
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putbuf’:
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c:58: error: ‘struct gdIOCtx’ has no member named ‘data’
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c: In function ‘_php_image_stream_ctxfree’:
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c:67: error: ‘struct gdIOCtx’ has no member named ‘data’
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c:68: error: ‘struct gdIOCtx’ has no member named ‘data’
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c:69: error: ‘struct gdIOCtx’ has no member named ‘data’
In file included from /root/lamp/php-5.4.1/ext/gd/gd.c:103:
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c: In function ‘_php_image_output_ctx’:
/root/lamp/php-5.4.1/ext/gd/gd_ctx.c:153: error: ‘gdIOCtx’ has no member named ‘data’
make: *** [ext/gd/gd.lo] Error 1
解决方法:
vim /opt/ws/gd2/include/gd_io.h
gdIOCtx结构中增加void *data;
格式如下
typedef struct gdIOCtx
{
int (*getC) (struct gdIOCtx *);
int (*getBuf) (struct gdIOCtx *, void *, int);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *);
void (*data);
}
gdIOCtx;