php7.4.30编译报错
1、编译
./configure --prefix=/data/program/php74 --with-config-file-path=/data/program/php74/etc \
--with-freetype=/data/program/freetype --enable-mysqlnd --with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-jpeg \
--enable-ftp --enable-xml --disable-rpath --enable-bcmath --enable-shmop \
--enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring \
--with-openssl --with-mhash --enable-pcntl --enable-sockets --enable-fpm --with-xmlrpc \
--enable-soap --enable-opcache=no --with-pear --with-zlib=/data/program/zlib \
--with-xpm=/usr/lib CPP=/usr/bin/cpp
2、make
make的时候报错了
[root@localhost php-7.4.30]# make -j4
......
ext/xmlrpc/libxmlrpc/encodings.o: In function `convert':
/data/software/php-7.4.30/ext/xmlrpc/libxmlrpc/encodings.c:63: undefined reference to `libiconv_open'
/data/software/php-7.4.30/ext/xmlrpc/libxmlrpc/encodings.c:70: undefined reference to `libiconv'
/data/software/php-7.4.30/ext/xmlrpc/libxmlrpc/encodings.c:86: undefined reference to `libiconv_close'
/data/software/php-7.4.30/ext/xmlrpc/libxmlrpc/encodings.c:86: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] 错误 1
make: *** 正在等待未完成的任务....
ext/iconv/iconv.o: In function `php_iconv_stream_filter_dtor':
......
解决方法
1、编辑Makefile
vim Makefile
#找到下面这行:
EXTRA_LIBS = -lcrypt ...
# 在行末添加 -liconv
例:
2、源码安装libiconv
wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz
tar -zxvf libiconv-1.17.tar.gz
cd libiconv-1.17
./configure --prefix=/usr/local/libiconv --enable-static --disable-shared --host=$host
make -j4
make install
安装完成后,将这一句 --with-iconv=/usr/local/libiconv/ 添加到编译PHP ./configure … 的最后面
例:
./configure --prefix=/data/program/php74 --with-config-file-path=/data/program/php74/etc \
--with-freetype=/data/program/freetype --enable-mysqlnd --with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-jpeg \
--enable-ftp --enable-xml --disable-rpath --enable-bcmath --enable-shmop \
--enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring \
--with-openssl --with-mhash --enable-pcntl --enable-sockets --enable-fpm --with-xmlrpc \
--enable-soap --enable-opcache=no --with-pear --with-zlib=/data/program/zlib \
--with-xpm=/usr/lib CPP=/usr/bin/cpp --with-iconv=/usr/local/libiconv/
<记得在重新编译PHP的时候 需要make clean>