deepin20 PHP 7.2GD库 无法启用 freetype的问题 “freetype-config not found”

7 篇文章 0 订阅

本次测试主要借鉴一下文章,,本次环境(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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值