我在安装php-5.4.38时,make时出现如下的错误:
In file included from /software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd.c:103:
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putc’:
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c:51: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putbuf’:
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c:58: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c: In function ‘_php_image_stream_ctxfree’:
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c:67: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c:68: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c:69: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c: In function ‘_php_image_output_ctx’:
/software/LAMP_Resource_Package/php-5.4.38/ext/gd/gd_ctx.c:153: 错误:‘gdIOCtx’ 没有名为 ‘data’ 的成员
make: *** [ext/gd/gd.lo] 错误 1
好像说这个错误算是php5.4的bug,下面对应的两篇文章有对应的说明:
https://bugs.php.net/bug.php?id=55224
https://bugs.php.net/bug.php?id=60108
解决方法如下:
修改gd2的文件: /usr/local/gd2/include/include/gd_io.h
在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;