本次测试主要借鉴一下文章,,本次环境(deepin20,php7.2)
以下是博客内容
环境:
Ubuntu 19.04 (Disco)
PHP 7.3.5
我在编译安装 PHP 时,遇到了 “freetype-config not found”的问题。
网上大多数的解决方案,都是尝试安装 libfreetype6-dev
apt-get install libfreetype6-dev
但是依然报错。
这是由于在 Ubuntu 19.04 中 apt-get 安装的 libfreetype6-dev 版本为 2.9.1-3
http://changelogs.ubuntu.com/changelogs/pool/main/f/freetype/freetype_2.9.1-3/changelog
在 changelog 中写到:
- The `freetype-config' script is no longer installed by default
(Closes: #871470, #886461). All packages depending on libfreetype6-dev
should use pkg-config to find the relevant CFLAGS and libraries.
freetype-config 被替代成 pkg-config ,新版本使用 pkg-config 管理 CFLAGS 和 库。
所以解决方法如下:
主要的思路就是用pkg-config代替freetype-config。
安装pkg-config
sudo apt install pkg-config
在 PHP 7.3.5 源码目录下的 ./configure 第 34504 行 和 第 36175 行:
if test "$PHP_FREETYPE_DIR" != "no"; then
for i in $PHP_FREETYPE_DIR /usr/local /usr; do
if test -f "$i/bin/freetype-config"; then
FREETYPE2_DIR=$i
FREETYPE2_CONFIG="$i/bin/freetype-config"
break
fi
done
if test -z "$FREETYPE2_DIR"; then
as_fn_error $? "freetype-config not found." "$LINENO" 5
fi
FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
替换为:
if test "$PHP_FREETYPE_DIR" != "no"; then
for i in $PHP_FREETYPE_DIR /usr/local /usr; do
if test -f "$i/bin/pkg-config"; then
FREETYPE2_DIR=$i
FREETYPE2_CONFIG="$i/bin/pkg-config"
break
fi
done
if test -z "$FREETYPE2_DIR"; then
as_fn_error $? "freetype-config not found." "$LINENO" 5
fi
FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG freetype2 --cflags`
FREETYPE2_LIBS=`$FREETYPE2_CONFIG freetype2 --libs`
在 ./ext/gd/config.m4 的 第 185 行 :
if test "$PHP_FREETYPE_DIR" != "no"; then
for i in $PHP_FREETYPE_DIR /usr/local /usr; do
if test -f "$i/bin/freetype-config"; then
FREETYPE2_DIR=$i
FREETYPE2_CONFIG="$i/bin/freetype-config"
break
fi
done
if test -z "$FREETYPE2_DIR"; then
AC_MSG_ERROR([freetype-config not found.])
fi
FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
替换为:
if test "$PHP_FREETYPE_DIR" != "no"; then
for i in $PHP_FREETYPE_DIR /usr/local /usr; do
if test -f "$i/bin/pkg-config"; then
FREETYPE2_DIR=$i
FREETYPE2_CONFIG="$i/bin/pkg-config"
break
fi
done
if test -z "$FREETYPE2_DIR"; then
AC_MSG_ERROR([freetype-config not found.])
fi
FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG freetype2 --cflags`
FREETYPE2_LIBS=`$FREETYPE2_CONFIG freetype2 --libs`
或者使用下方命令:
cd php-7.3.5/
sed -i "s/freetype-config/pkg-config/g" ./configure
sed -i "s/freetype-config/pkg-config/g" ./ext/gd/config.m4
sed -i "s/FREETYPE2_CONFIG --cflags/FREETYPE2_CONFIG freetype2 --cflags/g" ./configure
sed -i "s/FREETYPE2_CONFIG --libs/FREETYPE2_CONFIG freetype2 --cflags/g" ./configure