在php7.0上安装ncurses扩展

时间:2016-08-25 17:20:23

标签: php-7 php-extension php-ncurses

我尝试为php7.0安装ncurses扩展名,但我收到此错误

/bin/bash /tmp/pear/download/ncurses-1.0.2/libtool --mode=compile cc  -I. -I/tmp/pear/download/ncurses-1.0.2 -DPHP_ATOM_INC -I/tmp/pear/download/ncurses-1.0.2/include -I/tmp/pear/download/ncurses-1.0.2/main -I/tmp/pear/download/ncurses-1.0.2 -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/download/ncurses-1.0.2/ncurses.c -o ncurses.lo 
libtool: compile:  cc -I. -I/tmp/pear/download/ncurses-1.0.2 -DPHP_ATOM_INC -I/tmp/pear/download/ncurses-1.0.2/include -I/tmp/pear/download/ncurses-1.0.2/main -I/tmp/pear/download/ncurses-1.0.2 -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/download/ncurses-1.0.2/ncurses.c  -fPIC -DPIC -o .libs/ncurses.o
/tmp/pear/download/ncurses-1.0.2/ncurses.c:36:37: error: unknown type name ‘zend_rsrc_list_entry’
 static void ncurses_destruct_window(zend_rsrc_list_entry *rsrc TSRMLS_DC)
                                     ^
/tmp/pear/download/ncurses-1.0.2/ncurses.c:45:36: error: unknown type name ‘zend_rsrc_list_entry’
 static void ncurses_destruct_panel(zend_rsrc_list_entry *rsrc TSRMLS_DC)
                                    ^
/tmp/pear/download/ncurses-1.0.2/ncurses.c: In function ‘zm_startup_ncurses’:
/tmp/pear/download/ncurses-1.0.2/ncurses.c:247:57: error: ‘ncurses_destruct_window’ undeclared (first use in this function)
  le_ncurses_windows = zend_register_list_destructors_ex(ncurses_destruct_window, NULL, "ncurses_window", module_number);
                                                         ^
/tmp/pear/download/ncurses-1.0.2/ncurses.c:247:57: note: each undeclared identifier is reported only once for each function it appears in
/tmp/pear/download/ncurses-1.0.2/ncurses.c:249:56: error: ‘ncurses_destruct_panel’ undeclared (first use in this function)
  le_ncurses_panels = zend_register_list_destructors_ex(ncurses_destruct_panel, NULL, "ncurses_panel", module_number);
                                                        ^
Makefile:194: ошибка выполнения рецепта для цели «ncurses.lo»
make: *** [ncurses.lo] Ошибка 1

ошибка выполнения рецепта для цели «ncurses.lo»error in process run target

类似

2 个答案:

答案 0 :(得分:3)

有一个补丁可以应用于ncurses的v1.0.2 for php来修改它。一旦补丁被应用,扩展可以构建和安装。

必需的包(这些是Debian包名称): php-cli php-pear php-dev libncurses5-dev ncurses-doc libncursesw5-dev

以下所有命令均假定用户以root用户身份登录。打包命令特定于Debian。这些已经在Debian Stretch下进行了测试。

apt-get install php-cli php-pear php-dev libncurses5-dev ncurses-doc libncursesw5-dev

使用pecl获取ncurses的v1.0.2,使用wget获取补丁(ncurses.patch)。

cd /root
pecl download ncurses
mkdir /root/ncurses
cd /root/ncurses
tar -xvzf /root/ncurses-1.0.2.tgz
wget "https://bugs.php.net/patch-display.php?bug_id=71299&patch=ncurses-php7-support-again.patch&revision=1474549490&download=1" -O ncurses.patch

ncurses-1.0.2目录重命名为ncurses-php5,因为这是该修补程序所需的名称,并应用该修补程序。

mv ncurses-1.0.2 ncurses-php5
patch --strip=0 --verbose --ignore-whitespace <ncurses.patch

构建ncurses扩展。这将在ncurses.so中构建/root/ncurses/ncurses-php5/modules文件。

cd ncurses-php5
phpize
./configure
make

安装ncurses扩展。这会将ncurses.so文件放在/usr/lib/php/20151012中。此位置可能在其他发行版中有所不同。

make install

使ncurses.so扩展名可用于php 7.这些文件位置在其他发行版中可能有所不同。

cat <<'EndOfHereDoc' >/etc/php/7.0/mods-available/ncurses.ini
; configuration for php ncurses module
; priority=20
extension=ncurses.so
EndOfHereDoc
ln --symbolic /etc/php/7.0/mods-available/ncurses.ini /etc/php/7.0/cli/conf.d/20-ncurses.ini

验证ncurses确实可用。

php -m | grep ncurses

一切正常后,可以删除/root/ncurses目录,/root/ncurses-1.0.2.tgz文件和/root/channels.xml文件。

答案 1 :(得分:0)

我遇到了同样的问题,偶然发现了这个话题。这里提供的解决方案对我不起作用,但是我找到了另一个解决方案,可以在这里找到问题:https://github.com/OOPS-ORG-PHP/mod_ncurses 已对其进行修补并准备进行编译。 就像和我一样,只与其他人分享。