場(chǎng)景
在新安裝的 Arch 系統(tǒng)編譯安裝 PHP 失敗,提示錯(cuò)誤
configure: error: freetype-config not found.
編譯安裝的參數(shù)如下
sudo ./configure --prefix=/usr/local/php
--enable-fpm
--with-fpm-user=php-fpm
--with-fpm-group=php-fpm
--with-config-file-path=/usr/local/php/etc
--with-config-file-scan-dir=/usr/local/php/etc/conf.d
--with-openssl
--with-curl
--with-gd
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-freetype-dir=/usr
--enable-mbstring
--with-mysqli
--enable-opcache
--with-pdo-mysql
--with-openssl
--enable-mysqlnd
--with-webp-dir
--with-xpm-dir
原因
查找資料發(fā)現(xiàn)
They should really stop using this gross *-config script and start using pkg-config properly.
freetype-config 不再使用,而是使用 pkg-config
由于 php/ext/gd/config.m4 還是使用 freetype-config 而不是 pkg-config
導(dǎo)致報(bào) configure: error: freetype-config not found. 錯(cuò)誤.
詳細(xì)查看 php/ext/gd/config.m4 腳本
解決辦法
方法一
創(chuàng)建一個(gè)文件 /usr/sbin/freetype-config
#!/bin/sh
/usr/sbin/pkg-config freetype2 $@
重新編譯安裝,就可以了.
編譯出錯(cuò):/usr/local/src/php-7.2.9/ext/gd/gd.c:75:12: fatal error: ft2build.h: No such file or directory
方法二
編輯 php/ext/gd/config.m4 文件,把 freetype-config 替換為 pkg-config
而 FREETYPE2_CFLAGS, FREETYPE2_LIBS 增加參數(shù) freetype2
--- ext/gd/config.m4.orig
+++ ext/gd/config.m4
193c193
< if test -f "$i/bin/freetype-config"; then
---
> if test -f "$i/bin/pkg-config"; then
195c195
< FREETYPE2_CONFIG="$i/bin/freetype-config"
---
> FREETYPE2_CONFIG="$i/bin/pkg-config"
201c201
< AC_MSG_ERROR([freetype-config not found.])
---
> AC_MSG_ERROR([pkg-config not found.])
204,205c204,205
< FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
< FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
---
> FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags freetype2`
> FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs freetype2`
同理,configure 文件也做以上的修改,然后重新編譯即可.
最后采用 方法二 編譯安裝成功.
參考資料
things fail to build because freetype-config no longer exists
AUR(en)-php71