Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install ncurses extensions on php7.0

I try install ncurses extensions for php7.0 but I get this error

/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» is like error in process run target

like image 829
Naumov Avatar asked Aug 25 '16 17:08

Naumov


2 Answers

There is a patch which can be applied against v1.0.2 of ncurses for php to modify it for php 7. Once the patch has been applied, the extension can be built and installed.

Required packages (these are Debian package names): php-cli php-pear php-dev libncurses5-dev ncurses-doc libncursesw5-dev

All following commands assume the user is logged in as root. Packaging commands are specific to Debian. These have been tested under Debian Stretch.

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

Use pecl to get v1.0.2 of ncurses, and wget to get the patch (as 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

Rename the ncurses-1.0.2 directory to ncurses-php5 because that is the name which the patch expects, and apply the patch.

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

Build the ncurses extension. This will build the ncurses.so file in /root/ncurses/ncurses-php5/modules.

cd ncurses-php5
phpize
./configure
make

Install the ncurses extension. This will place the ncurses.so file in /usr/lib/php/20151012. This location may differ in other distributions.

make install

Make the ncurses.so extension available to php 7. These file locations may differ in other distributions.

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

Verify that ncurses is indeed available.

php -m | grep ncurses

Once everything is working, the /root/ncurses directory, /root/ncurses-1.0.2.tgz file, and /root/channels.xml file can be removed.

like image 123
Mark Neyhart Avatar answered Nov 14 '22 22:11

Mark Neyhart


I had the same problem and stumbled upon this topic. Soluthions provided here didn't work for me, but I found another solution, whitch is available here: https://github.com/OOPS-ORG-PHP/mod_ncurses It is patched and ready to compile. Just sharing with others that will struggle with this as I did.

like image 1
Boshentz Avatar answered Nov 14 '22 23:11

Boshentz