编译 PHP7 时出现的问题
编译 PHP7 源代码时, 可能会出现很多错误, 比如
/usr/local/src/php-7.3.5/ext/gd/libgd/gdkanji.c:379: undefined reference to `libiconv_open'
更多可见 https://bugs.php.net/bug.php?id=52611
此时, 在 ./configure 命令后加上选项 CFLAGS=-liconv
网上的评论是:
Whenever you see "undefined reference to `libiconv_open'", try make CFLAGS=-liconv
例如:
./configure CFLAGS=-liconv --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/conf --with-config-file-scan-dir=/usr/local/php7/conf.d --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-debug --enable-bcmath --enable-ftp --enable-sockets --enable-mbstring --enable-mbregex --enable-soap --enable-opcache --enable-calendar --enable-intl --enable-pcntl --enable-exif --enable-gd-jis-conv --enable-zend-signals --enable-maintainer-zts --enable-shmop --enable-sysvmsg --enable-sysvshm --enable-mysqlnd --enable-zip --disable-fileinfo --with-enchant --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --with-curl --with-iconv --with-pcre-regex --with-openssl --with-xsl --with-kerberos --with-zlib --with-gettext --with-gmp --with-mhash --with-pdo-mysql --with-pdo-pgsql --with-pgsql --with-pspell --with-libedit --with-readline --with-snmp --with-pear --with-mysqli --with-mysql-sock --with-ldap --with-ldap-sasl LDFLAGS="-L/usr/local/lib -lz"
--with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png --with-freetype-dir=/usr/local/freetype --with-libzip=/usr/local/lib64 --with-iconv-dir=/usr/local/lib LDFLAGS="-L/usr/lib -lz"make ZEND_EXTRA_LIBS='-liconv'make install
# apt-get install libldap2-dev
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_module_get_name'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_module_get_flags'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_uri_get_pin_value'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_module_finalize'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_module_release'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_module_load'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_config_option'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_modules_load_and_initialize'
/usr/local/lib/libgnutls.so.30: undefined reference to `p11_kit_module_initialize'
collect2: ld returned 1 exit status
如果解决不了上面这个问题, 那么也可以在编译 gnutls 前执行configure 如下,
./configure --without-p11-kit
make
make install
关于 gnutls 的编译, 参见问题2278