首页 > 电脑教程 > Linux教程 > Linux 未安装GD库的常见问题解决方法

Linux 未安装GD库的常见问题解决方法

2012-07-28 10:48:33 出处:动力软件园 责任编辑:动力软件园

Linux 安装GD库相关问题用于Linux 未安装GD库的常见问题解决方法

软件相关版本:
gd-2.0.35.tar.bz2
freetype-2.2.1.tar.gz
jpegsrc.v7.tar.gz
libpng-1.4.0.tar.bz2

freetype-2.2.1.tar.gz
jpegsrc.v7.tar.gz
libpng-1.4.0.tar.bz2
这三个库必须安装在GD之前

采用软件默认安装目录:/usr/local

#tar fvxj freetype-2.2.1.tar.gz
#cd freetype-2.2.1
#./configure –enable-shared (生成共享库)(不过,默认是—enable-shared)
#make
#make install
freetype-2.2.1安装完成

#tar fvxz jpegsrc.v7.tar.gz
#cd jpeg-7
#./configure –enable-shared (生成共享库)(不过,默认是—enable-shared)
#make
#make install
jpegsrc.v7安装完成

#tar libpng-1.4.0.tar.bz2
#cd libpng-1.4.0
#cd scripts
#cp makefile.linux  ../makefile
#cd ..
#make
#make install
libpng-1.4.0安装完成

#tar fvxj gd-2.0.35.tar.bz2
#cd gd-2.0.35
#./configure –with-freetype –with-jpeg –with-png
结果:** Configuration summary for gd 2.0.34:

   Support for PNG library:          yes
   Support for JPEG library:         yes
   Support for Freetype 2.x library: yes
   Support for Fontconfig library:   no
   Support for Xpm library:          no
   Support for pthreads:             yes

configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/Makefile
config.status: creating config/gdlib-config
config.status: creating test/Makefile
config.status: creating config.h
config.status: executing depfiles commands

#make
结果:
cd . && /bin/sh /root/gd-2.0.35/config/missing --run aclocal-1.9 -I config
aclocal:configure.ac:64: warning: macro `AM_ICONV not found in library
 cd . && /bin/sh /root/gd-2.0.35/config/missing --run automake-1.9 --foreign
cd . && /bin/sh /root/gd-2.0.35/config/missing --run autoconf
configure.ac:64: error: possibly undefined macro: AM_ICONV
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
make: *** [configure] 错误 1

遇此问题,只要再make一次,可解决
#make
但又会再遇如下错误:
./.libs/libgd.so: undefined reference to `png_check_sig
collect2: ld returned 1 exit status
make[2]: *** [annotate] 错误 1
make[2]: Leaving directory `/root/gd-2.0.35
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/root/gd-2.0.35
make: *** [all] 错误 2
You have mail in /var/spool/mail/root

此问题的解决办法:
新的 libpng 1.4版本,去掉了png_check_sig函数,替换为了png_sig_check函数
,于是编辑gd库的 gd_png.c文件,将
if (!png_check_sig (sig, 8)) { /* bad signature */
  return NULL;
}
修改为
if (png_sig_cmp (sig, 0, 8)) { /* bad signature */
  return NULL;
}
#make install

以上以默认路径方式的GD安装完成。

自定义路径安装,如下:
GD:  /usr/local/gd
Freetype: /usr/local/freetype
Jpeg:  /usr/local/jpeg
Libpng:  /usr/local/png

#tar fvxj freetype-2.2.1.tar.gz
#cd freetype-2.2.1
#./configure –prefix=/usr/local/freetype –enable-shared (生成共享库)(不过,默认是—enable-shared)
#make
#make install
freetype-2.2.1安装完成

#tar fvxz jpegsrc.v7.tar.gz
#cd jpeg-7
#./configure  --prefix=/usr/local/jpeg –enable-shared (生成共享库)(不过,默认是—enable-shared)
#make
#make install
jpegsrc.v7安装完成

#tar libpng-1.4.0.tar.bz2
#cd libpng-1.4.0
#./configure –prefix=/usr/local/png
#make
#make install
libpng-1.4.0安装完成

#tar fvxj gd-2.0.35.tar.bz2
#cd gd-2.0.35
#./configure –prefix=/usr/local/gd –with-freetype=/usr/local/freetype
>--with-jpeg=/usr/local/jpeg –with-png=/usr/local/png
(自定义安装的包,需要指定路径)
#make (会再次出现上面的问题)

#make
同时也要修改gd_png.c文件,同上;
但又会出现如下问题:
gd_png.c:16:53: error: png.h: No such file or directory
gd_png.c:47: error: expected specifier-qualifier-list before jmp_buf
gd_png.c:54: error: expected ) before png_ptr
gd_png.c:82: error: expected ) before png_ptr
gd_png.c:92: error: expected ) before png_ptr
gd_png.c:98: error: expected ) before png_ptr
gd_png.c: In function gdImageCreateFromPngCtx:
gd_png.c:125: error: png_byte undeclared (first use in this function)
gd_png.c:125: error: (Each undeclared identifier is reported only once
gd_png.c:125: error: for each function it appears in.)
gd_png.c:125: error: expected ; before sig
gd_png.c:126: error: png_structp undeclared (first use in this function)
gd_png.c:126: error: expected ; before png_ptr
gd_png.c:127: error: png_infop undeclared (first use in this function)
gd_png.c:127: error: expected ; before info_ptr
gd_png.c:128: error: png_uint_32 undeclared (first use in this function)
gd_png.c:128: error: expected ; before width
gd_png.c:131: error: png_colorp undeclared (first use in this function)
gd_png.c:131: error: expected ; before palette
gd_png.c:132: error: png_color_16p undeclared (first use in this function)
gd_png.c:132: error: expected ; before trans_gray_rgb
gd_png.c:133: error: expected ; before trans_color_rgb
gd_png.c:134: error: png_bytep undeclared (first use in this function)
gd_png.c:134: error: expected ; before trans
gd_png.c:135: error: expected ; before image_data
gd_png.c:136: error: png_bytepp undeclared (first use in this function)
gd_png.c:136: error: expected ; before row_pointers
gd_png.c:144: error: sig undeclared (first use in this function)
gd_png.c:157: error: png_ptr undeclared (first use in this function)
gd_png.c:157: error: PNG_LIBPNG_VER_STRING undeclared (first use in this function)
gd_png.c:157: error: gdPngErrorHandler undeclared (first use in this function)
gd_png.c:166: error: info_ptr undeclared (first use in this function)
gd_png.c:182: error: jmpbuf_wrapper has no member named jmpbuf
gd_png.c:192: error: gdPngReadData undeclared (first use in this function)
gd_png.c:195: error: width undeclared (first use in this function)
gd_png.c:195: error: height undeclared (first use in this function)
gd_png.c:196: error: PNG_COLOR_TYPE_RGB undeclared (first use in this function)
gd_png.c:196: error: PNG_COLOR_TYPE_RGB_ALPHA undeclared (first use in this function)
gd_png.c:204: error: image_data undeclared (first use in this function)
gd_png.c:205: error: row_pointers undeclared (first use in this function)
gd_png.c:220: error: jmpbuf_wrapper has no member named jmpbuf
gd_png.c:233: error: PNG_COLOR_TYPE_PALETTE undeclared (first use in this function)
gd_png.c:234: error: palette undeclared (first use in this function)
gd_png.c:238: error: PNG_INFO_tRNS undeclared (first use in this function)
gd_png.c:246: error: trans undeclared (first use in this function)
gd_png.c:258: error: PNG_COLOR_TYPE_GRAY undeclared (first use in this function)
gd_png.c:259: error: PNG_COLOR_TYPE_GRAY_ALPHA undeclared (first use in this function)
gd_png.c:261: error: expected ) before gdMalloc
gd_png.c:280: error: trans_gray_rgb undeclared (first use in this function)
gd_png.c:305: error: trans_color_rgb undeclared (first use in this function)
gd_png.c:322: error: rowbytes undeclared (first use in this function)
gd_png.c:327: error: expected ; before gdMalloc
gd_png.c:345: error: expected ; before gdMalloc
gd_png.c:357: error: h undeclared (first use in this function)
gd_png.c:381: error: PNG_INTERLACE_ADAM7 undeclared (first use in this function)
gd_png.c:389: error: w undeclared (first use in this function)
gd_png.c:390: error: expected =, ,, ;, asm or __attribute__ before r
gd_png.c:390: error: r undeclared (first use in this function)
gd_png.c:391: error: expected =, ,, ;, asm or __attribute__ before g
gd_png.c:391: error: g undeclared (first use in this function)
gd_png.c:392: error: expected =, ,, ;, asm or __attribute__ before b
gd_png.c:392: error: b undeclared (first use in this function)
gd_png.c:401: error: expected =, ,, ;, asm or __attribute__ before r
gd_png.c:402: error: expected =, ,, ;, asm or __attribute__ before g
gd_png.c:403: error: expected =, ,, ;, asm or __attribute__ before b
gd_png.c:410: error: expected =, ,, ;, asm or __attribute__ before a
gd_png.c:410: error: a undeclared (first use in this function)
gd_png.c:419: error: expected =, ,, ;, asm or __attribute__ before idx
gd_png.c:419: error: idx undeclared (first use in this function)
gd_png.c: In function gdImagePngCtxEx:
gd_png.c:499: error: png_byte undeclared (first use in this function)
gd_png.c:499: error: expected ; before trans_values
gd_png.c:500: error: png_color_16 undeclared (first use in this function)
gd_png.c:500: error: expected ; before trans_rgb_value
gd_png.c:501: error: png_color undeclared (first use in this function)
gd_png.c:501: error: expected ; before palette
gd_png.c:502: error: png_structp undeclared (first use in this function)
gd_png.c:502: error: expected ; before png_ptr
gd_png.c:503: error: png_infop undeclared (first use in this function)
gd_png.c:503: error: expected ; before info_ptr
gd_png.c:508: error: png_ptr undeclared (first use in this function)
gd_png.c:508: error: PNG_LIBPNG_VER_STRING undeclared (first use in this function)
gd_png.c:509: error: gdPngErrorHandler undeclared (first use in this function)
gd_png.c:520: error: info_ptr undeclared (first use in this function)
gd_png.c:524: error: png_infopp undeclared (first use in this function)
gd_png.c:529: error: jmpbuf_wrapper has no member named jmpbuf
gd_png.c:537: error: gdPngWriteData undeclared (first use in this function)
gd_png.c:538: error: gdPngFlushData undeclared (first use in this function)
gd_png.c:595: error: PNG_INTERLACE_ADAM7 undeclared (first use in this function)
gd_png.c:595: error: PNG_INTERLACE_NONE undeclared (first use in this function)
gd_png.c:602: error: PNG_COLOR_TYPE_RGB_ALPHA undeclared (first use in this function)
gd_png.c:603: error: PNG_COMPRESSION_TYPE_DEFAULT undeclared (first use in this function)
gd_png.c:604: error: PNG_FILTER_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:617: error: PNG_COLOR_TYPE_PALETTE undeclared (first use in this function)
gd_png.c:623: error: trans_rgb_value undeclared (first use in this function)
gd_png.c:672: error: trans_values undeclared (first use in this function)
gd_png.c:694: error: palette undeclared (first use in this function)
gd_png.c:725: error: png_bytep undeclared (first use in this function)
gd_png.c:725: error: row_pointers undeclared (first use in this function)
gd_png.c:731: error: prow_pointers undeclared (first use in this function)
gd_png.c:747: error: expected ) before gdMalloc
gd_png.c:804: error: expected ) before gdMalloc
make[2]: *** [gd_png.lo] 错误 1
make[2]: Leaving directory `/root/gd-2.0.35
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/root/gd-2.0.35
make: *** [all] 错误 2

解决上面问题:
降低libpng的版本
将/usr/local/png/include/libpng14/pngconf.h  png.h拷贝到gd-2.0.35安装目录下
Cp –pv /usr/local/png/include/ libpng14/pngconf.h /root/ gd-2.0.35
cp –pv /usr/local/png/include/ libpng14/png.h /root/ gd-2.0.35

#make (通过)
#make install

自定义目录安装完成

热门软件
() ()
相关文章