我尝试为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
最佳答案
有一个补丁可以针对php的ncurses v1.0.2进行应用,以针对php 7进行修改。一旦应用了补丁,就可以构建和安装扩展。
必需的软件包(这些是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
扩展名可用于php7。在其他发行版中,这些文件位置可能有所不同。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
文件。关于php-7 - 在php7.0上安装ncurses扩展,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39151234/