编译php扩展时出错,步骤如下:
1 cd path/to/php-src/ext
2 ./ext_skel --extname=example
3 cd ..
4 ./buildconf
5 ./configure --with-example
5 make
ok,就在编译的时候解析器报错:
path/to/php-src/Zend/zend_language_parser.y:50.1-5: invalid directive: `%code'
path/to/php-src/Zend/zend_language_parser.y:50.7-14: syntax error, unexpected "identifier"
原因是%code是bison2.3+之后才引入的,我的机器上bison版本是1.875c,因此不支持,解决方法是:
1 下载高版本的bison并安装
2 或者修改path/to/php-src/Zend/zend_language_parser.y,由于我没有root权限,bison是安装在/usr/bin/bison的,因此采用方案2,具体如下:
将%code requires { 修改为%{
将} 修改为%}
make clean
make Ok.