Can not build cphalcon 2.1.x with php 7.0.5

Hello.

On my virtual machine can't compile phalcon.

ubuntu 15.10

php PHP 7.0.5-2+deb.sury.org~wily+1 (cli) ( NTS )

Zephir version 0.9.2 a-dev

git clone https://github.com/phalcon/zephir zephir-ubuntu
cd zephir
./install -c

git clone http://github.com/phalcon/cphalcon
cd cphalcon
git checkout 2.1.x
zephir build --backend=ZendEngine3
zephir_parser extension not loaded, compiling it
Parser statistics: 127 terminals, 99 nonterminals, 459 rules
                   947 states, 0 parser table entries, 0 conflicts
Preparing for parser compilation...
Compiling the parser...
/home/mercury/zephir-ubuntu/parser/parser/parser.c: In function 'yy_reduce':
/home/mercury/zephir-ubuntu/parser/parser/parser.c:8763:38: warning: passing argument 2 of 'xx_ret_scall' from incompatible pointer type [-Wincompatible-pointer-types]
  yygotominor.yy132 = xx_ret_scall(0, yymsp[-6].minor.yy0, 1, yymsp[-3].minor.yy0, NULL, status->scanner_state);
                                      ^
/home/mercury/zephir-ubuntu/parser/parser/parser.c:1189:14: note: expected 'char *' but argument is of type 'xx_parser_token * {aka struct _xx_parser_token *}'
 static zval *xx_ret_scall(int dynamic_class, char *class_name, int dynamic_method, xx_parser_token *M, zval *parameters, xx_scanner_state *state)
              ^
/home/mercury/zephir-ubuntu/parser/parser/parser.c:8775:38: warning: passing argument 2 of 'xx_ret_scall' from incompatible pointer type [-Wincompatible-pointer-types]
  yygotominor.yy132 = xx_ret_scall(0, yymsp[-7].minor.yy0, 1, yymsp[-4].minor.yy0, yymsp[-1].minor.yy132, status->scanner_state);
                                      ^
/home/mercury/zephir-ubuntu/parser/parser/parser.c:1189:14: note: expected 'char *' but argument is of type 'xx_parser_token * {aka struct _xx_parser_token *}'
 static zval *xx_ret_scall(int dynamic_class, char *class_name, int dynamic_method, xx_parser_token *M, zval *parameters, xx_scanner_state *state)
              ^
In file included from /usr/include/string.h:634:0,
                 from /home/mercury/zephir-ubuntu/parser/parser/scanner.c:22:
/home/mercury/zephir-ubuntu/parser/parser/scanner.c:30:14: error: expected identifier or '(' before '__extension__'
 extern char *strndup(const char *s, size_t len);
              ^
/home/mercury/zephir-ubuntu/parser/parser/scanner.c: In function 'xx_get_token':
/home/mercury/zephir-ubuntu/parser/parser/scanner.c:1276:4: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
    free(token->value);
    ^
/home/mercury/zephir-ubuntu/parser/parser/scanner.c:1276:4: warning: incompatible implicit declaration of built-in function 'free'
/home/mercury/zephir-ubuntu/parser/parser/scanner.c:1276:4: note: include '<stdlib.h>' or provide a declaration of 'free'
make: *** [parser/scanner.lo] Error 1
make: *** Waiting for unfinished jobs....

libtool: compile:  gcc -I. -I/home/mercury/zephir-ubuntu/parser -DPHP_ATOM_INC -I/home/mercury/zephir-ubuntu/parser/include -I/home/mercury/zephir-ubuntu/parser/main -I/home/mercury/zephir-ubuntu/parser -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 /home/mercury/zephir-ubuntu/parser/zephir_parser.c  -fPIC -DPIC -o .libs/zephir_parser.o
libtool: compile:  gcc -I. -I/home/mercury/zephir-ubuntu/parser -DPHP_ATOM_INC -I/home/mercury/zephir-ubuntu/parser/include -I/home/mercury/zephir-ubuntu/parser/main -I/home/mercury/zephir-ubuntu/parser -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 /home/mercury/zephir-ubuntu/parser/parser/parser.c  -fPIC -DPIC -o parser/.libs/parser.o
libtool: compile:  gcc -I. -I/home/mercury/zephir-ubuntu/parser -DPHP_ATOM_INC -I/home/mercury/zephir-ubuntu/parser/include -I/home/mercury/zephir-ubuntu/parser/main -I/home/mercury/zephir-ubuntu/parser -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 /home/mercury/zephir-ubuntu/parser/parser/scanner.c  -fPIC -DPIC -o parser/.libs/scanner.o
Makefile:198: recipe for target 'parser/scanner.lo' failed

PHP Warning:  copy(modules/zephir_parser.so): failed to open stream: No such file or directory in /home/mercury/zephir-ubuntu/Library/Compiler.php on line 271
Zephir\Exception: The zephir parser extension could not be found or compiled!


55.8k

php 7 doesnt work anyways even if we make it work...

which php and which php-config should be pointing to php 7. go to zephir dir /parser . Than type

make clean
phpize clean

if you type php -v in terminal it should see php 7.0.5. dev or whatever, but my guess is that for you it shows 5.6.... whatever.

in /etc/alternatives/ are the shortcuts for the php stuff. type

ll | grep "php"

and you will see all the symbolic links with their path. Me personally i play with those when i try to make it compile and see the error in my application :-)



5.7k

I did it in "zephir dir /parser", but not work

make clean
phpize clean

php -v

PHP 7.0.5-2+deb.sury.org~wily+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

ll | grep "php"

lrwxrwxrwx   1 root root    21 Apr  1 17:50 libphp5 -> /usr/lib/libphp5.6.so
lrwxrwxrwx   1 root root    15 Apr  1 17:50 php -> /usr/bin/php7.0*
lrwxrwxrwx   1 root root    31 Apr  1 17:50 php.1.gz -> /usr/share/man/man1/php7.0.1.gz
lrwxrwxrwx   1 root root    22 Apr  7 11:37 php-config -> /usr/bin/php-config7.0*
lrwxrwxrwx   1 root root    38 Apr  7 11:37 php-config.1.gz -> /usr/share/man/man1/php-config7.0.1.gz
lrwxrwxrwx   1 root root    18 Apr  7 11:37 phpize -> /usr/bin/phpize7.0*
lrwxrwxrwx   1 root root    34 Apr  7 11:37 phpize.1.gz -> /usr/share/man/man1/phpize7.0.1.gz


55.8k

hmmm this PHP 7.0.5-2+deb.sury.org~wily+1 (cli) ( NTS ) seems very suspicious ... how did you install your php 7 ?



5.7k
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0


55.8k

aaah ok.. this screwed me up once before.... do you have skype ?



55.8k
edited Apr '16

or maybe if this is a virtual machine you can re-isntall easily.. check here http://tecadmin.net/install-php-7-on-ubuntu/

and maybe try to isntall php7.0-dev

apt-get instlal php7.0-dev or some other package. it sohuld fix it...

but i dont think anyone should be using those repos, they are causing too much damage



55.8k

ok i will add you in 5 mins, edit your message ( if you want to hide your skype :-) )



5.7k

Thank you. I understood the matter in a repository. I reinstall php



5.7k

Hello. I'm still getting errors.

I reinstall ubuntu, install apache, php7, zephir (master branch), cphalcon(2.1.x branch)

zephir build --backend=ZendEngine3

zephir_parser extension not loaded, compiling it
Parser statistics: 127 terminals, 99 nonterminals, 459 rules
                   947 states, 0 parser table entries, 0 conflicts
Preparing for parser compilation...
Compiling the parser...
/home/mercury/zephir/parser/parser/parser.c: In function 'yy_reduce':
/home/mercury/zephir/parser/parser/parser.c:8763:38: warning: passing argument 2 of 'xx_ret_scall' from incompatible pointer type [-Wincompatible-pointer-types]
  yygotominor.yy132 = xx_ret_scall(0, yymsp[-6].minor.yy0, 1, yymsp[-3].minor.yy0, NULL, status->scanner_state);
                                      ^
/home/mercury/zephir/parser/parser/parser.c:1189:14: note: expected 'char *' but argument is of type 'xx_parser_token * {aka struct _xx_parser_token *}'
 static zval *xx_ret_scall(int dynamic_class, char *class_name, int dynamic_method, xx_parser_token *M, zval *parameters, xx_scanner_state *state)
              ^
/home/mercury/zephir/parser/parser/parser.c:8775:38: warning: passing argument 2 of 'xx_ret_scall' from incompatible pointer type [-Wincompatible-pointer-types]
  yygotominor.yy132 = xx_ret_scall(0, yymsp[-7].minor.yy0, 1, yymsp[-4].minor.yy0, yymsp[-1].minor.yy132, status->scanner_state);
                                      ^
/home/mercury/zephir/parser/parser/parser.c:1189:14: note: expected 'char *' but argument is of type 'xx_parser_token * {aka struct _xx_parser_token *}'
 static zval *xx_ret_scall(int dynamic_class, char *class_name, int dynamic_method, xx_parser_token *M, zval *parameters, xx_scanner_state *state)
              ^
In file included from /usr/include/string.h:634:0,
                 from /home/mercury/zephir/parser/parser/scanner.c:22:
/home/mercury/zephir/parser/parser/scanner.c:30:14: error: expected identifier or '(' before '__extension__'
 extern char *strndup(const char *s, size_t len);
              ^
/home/mercury/zephir/parser/parser/scanner.c: In function 'xx_get_token':
/home/mercury/zephir/parser/parser/scanner.c:1276:4: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
    free(token->value);
    ^
/home/mercury/zephir/parser/parser/scanner.c:1276:4: warning: incompatible implicit declaration of built-in function 'free'
/home/mercury/zephir/parser/parser/scanner.c:1276:4: note: include '<stdlib.h>' or provide a declaration of 'free'
make: *** [parser/scanner.lo] Error 1
make: *** Waiting for unfinished jobs....

libtool: compile:  gcc -I. -I/home/mercury/zephir/parser -DPHP_ATOM_INC -I/home/mercury/zephir/parser/include -I/home/mercury/zephir/parser/main -I/home/mercury/zephir/parser -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 /home/mercury/zephir/parser/zephir_parser.c  -fPIC -DPIC -o .libs/zephir_parser.o
libtool: compile:  gcc -I. -I/home/mercury/zephir/parser -DPHP_ATOM_INC -I/home/mercury/zephir/parser/include -I/home/mercury/zephir/parser/main -I/home/mercury/zephir/parser -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 /home/mercury/zephir/parser/parser/parser.c  -fPIC -DPIC -o parser/.libs/parser.o
libtool: compile:  gcc -I. -I/home/mercury/zephir/parser -DPHP_ATOM_INC -I/home/mercury/zephir/parser/include -I/home/mercury/zephir/parser/main -I/home/mercury/zephir/parser -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 /home/mercury/zephir/parser/parser/scanner.c  -fPIC -DPIC -o parser/.libs/scanner.o
Makefile:198: recipe for target 'parser/scanner.lo' failed

PHP Warning:  copy(modules/zephir_parser.so): failed to open stream: No such file or directory in /home/mercury/zephir/Library/Compiler.php on line 271
Zephir\Exception: The zephir parser extension could not be found or compiled!
edited Apr '16

Bumping this thread since i have the EXACVT same issue. But I'm using Arch Linix



55.8k

Dan didnt wrote me in skype to check it with teamview...

make sure both php and phpize are pointing to php 7 the only thing that is crossing my mind....



55.8k

aaaa yea... there is a thirth one ... so php, phpize and php-config those 3 should be "pointing to php7"

in ubuntu is in /etc/alternatives/ dir , where you can change the shorcuts



5.7k

Thanks. php-config It helped when I replaced php7 on php5.6.

Since that time, I had not yet checked php7. Sorry I did not write in skype, I was busy.

I could not understand why not set phalcon. But when php-config deleted, php5-dev reinstalled. Everything started to work

aaaa yea... there is a thirth one ... so php, phpize and php-config those 3 should be "pointing to php7"

in ubuntu is in /etc/alternatives/ dir , where you can change the shorcuts

I'm still having problems and all the binaries are php7. I don't have other version installed currently. This is so frustrating and keeps me from taking on new projects with phalcon :(

But shame on me if i give up :)

Hurray!! After some code digging I found a solution. My only conclusion is that there is typo in the code since

extern char *strndup(const char *s, size_t len);

seems to be out of context in the file scanner.re

If that row is removed (row 30). Then the compilation proceeds and finishes succesfully.

edited Apr '16

I had this exact same issue when trying to compile Zephir in Ubuntu 15.04 with PHP 7.0.5:

./bin/zephir compile

warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
    free(token->value);
    ^

and followed the instructions provided by @joyider editing the file located at zephir/parser/parser/scanner.re and removing the line above then it compiled succesfully.

Thanks!



5.7k

Hello @joyider,

Can you show a link to github?

edited Apr '16

When I try to install phalcon v2.1.x always get this:

zephir build --backend=ZendEngine3 Segmentation fault (core dumped) Segmentation fault (core dumped) Segmentation fault (core dumped) PHP Fatal error: Uncaught Error: Call to undefined function Zephir\zephirparsefile() in /home/work/github/zephir/Library/CompilerFile.php:173 Stack trace:

/home/work/github/zephir/Library/CompilerFile.php(563): Zephir\CompilerFile->genIR(Object(Zephir\Compiler)) /home/work/github/zephir/Library/Compiler.php(318): Zephir\CompilerFile->preCompile(Object(Zephir\Compiler)) /home/work/github/zephir/Library/Compiler.php(357): Zephir\Compiler->preCompile('phalcon/acl/ada...') /home/work/github/zephir/Library/Compiler.php(904): Zephir\Compiler->recursivePreCompile('phalcon') /home/work/github/zephir/Library/Compiler.php(1131): Zephir\Compiler->generate(Object(Zephir\Commands\CommandBuild)) /home/work/github/zephir/Library/Compiler.php(1267): Zephir\Compiler->compile(Object(Zephir\Commands\CommandBuild), false) /home/work/github/zephir/Library/Compiler.php(1348): Zephir\Compiler->install(Object(Zephir\Commands\CommandBuild), false) /home/work/github/zephir/Library/Commands/CommandAbstract.php(108): Zephir\Com in /home/work/github/zephir/Library/CompilerFile.php on line 17

Zephir cloned from master branch, version 0.9.2a-dev. Any ideas?

phalcon does not support php 7 yet

https://github.com/phalcon/cphalcon/issues/11550

https://github.com/phalcon/zephir/issues/1218

I now but Phalcon 2.1.x has beta PHP7 support... I heard from more people that they are running and it's stable regardless that it is still in Beta.



818

I somehow resolved this problem today. It wasted me a day to figure out what the problem is! It is caused by a bug from the latest commit of Zephir. Blow is what I do (make sure php and phpize are pointing to php 7, if you have multiple php versions installed):

git clone http://github.com/phalcon/zephir

cd zephir

git reset db989ac2bc457310a6d38c8f9e7066e7183e1d3d --hard

cd parser/parser

./build_linux.sh

cd ..

make clean

phpize --clean

phpize

./configure

make && make install

echo "extension=zephirparser.so" > /etc/php.d/51-zephirparser.ini

service php-fpm restart

cd /path/to/cphalcon-2.1.x

zephir build --backend=ZendEngine3

echo "extension=phalcon.so" > /etc/php.d/52-phalcon.ini

service php-fpm restart

Now you can use "php -m | grep phalcon" to check if phalcon is successfully loaded. The most important thing is to reset zephir to several commits ago. Hope this is helpful.

phalcon does not support php 7 yet

https://github.com/phalcon/cphalcon/issues/11550

https://github.com/phalcon/zephir/issues/1218

I now but Phalcon 2.1.x has beta PHP7 support... I heard from more people that they are running and it's stable regardless that it is still in Beta.

I somehow resolved this problem today. It wasted me a day to figure out what the problem is! It is caused by a bug from the latest commit of Zephir. Blow is what I do (make sure php and phpize are pointing to php 7, if you have multiple php versions installed):

Seems you are right, compiled successfull. I have other problems now, so can't try out, but will let you know once I setup everything. Thx a lot.



818

No need to do this now. I submitted this issue to zephir github yesterday and the problem was resolved by andresgutierrez. Just checkout the latest master of zephir from github and build cphalcon with PHP 7.

I somehow resolved this problem today. It wasted me a day to figure out what the problem is! It is caused by a bug from the latest commit of Zephir. Blow is what I do (make sure php and phpize are pointing to php 7, if you have multiple php versions installed):

Seems you are right, compiled successfull. I have other problems now, so can't try out, but will let you know once I setup everything. Thx a lot.



55.8k

and Tod does your application works with php 7 ?

No need to do this now. I submitted this issue to zephir github yesterday and the problem was resolved by andresgutierrez. Just checkout the latest master of zephir from github and build cphalcon with PHP 7.

I can confirm. Recompiled with latest zephir (from master) and now works. Everything is OK now. Thx a lot.