linux下为php添加iconv模块的方法
./configure--with-mysql=/backup/mysql--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-curl--with-gd--enable-gd-native-ttf--with-apxs2=/usr/local/apache/bin/apxs--enable-sockets--with-iconv
make时提示:
..................................................... ext/iconv/.libs/iconv.o(.text+0x1738):Infunction`zif_iconv_mime_encode': /home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1017:undefinedreferenceto`libiconv_open' ext/iconv/.libs/iconv.o(.text+0x1756):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1031:undefinedreferenceto`libiconv_open' ext/iconv/.libs/iconv.o(.text+0x1993):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1290:undefinedreferenceto`libiconv_close' ext/iconv/.libs/iconv.o(.text+0x19ad):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1293:undefinedreferenceto`libiconv_close' ext/iconv/.libs/iconv.o(.text+0x1b01):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1102:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x1b33):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1134:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x1b5e):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1150:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x1e10):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1202:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x1e3c):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1233:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x207f):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:1277:moreundefinedreferencesto`libiconv'follow ext/iconv/.libs/iconv.o(.text+0x2c08):Infunction`php_iconv_stream_filter_dtor': /home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:2393:undefinedreferenceto`libiconv_close' ext/iconv/.libs/iconv.o(.text+0x2cf2):Infunction`php_iconv_stream_filter_append_bucket': /home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:2543:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x2d34):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:2543:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x2de7):/home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:2465:undefinedreferenceto`libiconv' ext/iconv/.libs/iconv.o(.text+0x30e2):Infunction`php_iconv_stream_filter_factory_create': /home/jjdai/work/zhupiter/php-5.2.0/ext/iconv/iconv.c:2419:undefinedreferenceto`libiconv_open' collect2:ldreturned1exitstatus make:***[sapi/cli/php]Error1
解决方法
wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz tar-zxvflibiconv-1.13.1.tar.gz cdlibiconv-1.13.1 ./configure--prefix=/usr/local/libiconv make makeinstall
再检查php
#./configure--with-mysql=/backup/mysql--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-curl--with-gd--enable-gd-native-ttf--with-apxs2=/usr/local/apache/bin/apxs--enable-sockets--with-iconv=/usr/local/libiconv #make #makeinstall
另一种解决方法为去除iconv模块也能正常编译php,如下:
編輯Makefile大約77行左右的地方:
EXTRA_LIBS=.....-lcrypt
在最後加上-liconv,例如:
EXTRA_LIBS=.....-lcrypt-liconv
再运行make就可以了。