我正在用多个PHP版本(7和5.6)安装我的新笔记本,当完美编译PHP-7.0后,我在PHP-5.6编译过程中出现标记器错误。
步骤
sudo mkdir /opt/source
cd /opt/source
sudo git clone https://github.com/php/php-src.git
cd php-src
sudo git checkout PHP-5.6.17
sudo ./configure --prefix=/opt/php-5.6 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --with-fpm-user=nginx --with-fpm-group=nginx --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-gd --with-jpeg-dir=/usr/lib/ --enable-fpm
错误
/bin/bash /opt/source/php-src/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/standard/ -I/opt/source/php-src/ext/standard/ -DPHP_ATOM_INC -I/opt/source/php-src/include -I/opt/source/php-src/main -I/opt/source/php-src -I/opt/source/php-src/ext/date/lib -I/opt/source/php-src/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/c-client -I/opt/source/php-src/ext/mbstring/oniguruma -I/opt/source/php-src/ext/mbstring/libmbfl -I/opt/source/php-src/ext/mbstring/libmbfl/mbfl -I/usr/include/postgresql -I/opt/source/php-src/ext/sqlite3/libsqlite -I/opt/source/php-src/ext/zip/lib -I/opt/source/php-src/TSRM -I/opt/source/php-src/Zend -I/usr/include -g -O2 -fvisibility=hidden -c /opt/source/php-src/ext/standard/info.c -o ext/standard/info.lo
/bin/bash /opt/source/php-src/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/tokenizer/ -I/opt/source/php-src/ext/tokenizer/ -DPHP_ATOM_INC -I/opt/source/php-src/include -I/opt/source/php-src/main -I/opt/source/php-src -I/opt/source/php-src/ext/date/lib -I/opt/source/php-src/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/c-client -I/opt/source/php-src/ext/mbstring/oniguruma -I/opt/source/php-src/ext/mbstring/libmbfl -I/opt/source/php-src/ext/mbstring/libmbfl/mbfl -I/usr/include/postgresql -I/opt/source/php-src/ext/sqlite3/libsqlite -I/opt/source/php-src/ext/zip/lib -I/opt/source/php-src/TSRM -I/opt/source/php-src/Zend -I/usr/include -g -O2 -fvisibility=hidden -c /opt/source/php-src/ext/tokenizer/tokenizer.c -o ext/tokenizer/tokenizer.lo
/bin/bash /opt/source/php-src/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/tokenizer/ -I/opt/source/php-src/ext/tokenizer/ -DPHP_ATOM_INC -I/opt/source/php-src/include -I/opt/source/php-src/main -I/opt/source/php-src -I/opt/source/php-src/ext/date/lib -I/opt/source/php-src/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/c-client -I/opt/source/php-src/ext/mbstring/oniguruma -I/opt/source/php-src/ext/mbstring/libmbfl -I/opt/source/php-src/ext/mbstring/libmbfl/mbfl -I/usr/include/postgresql -I/opt/source/php-src/ext/sqlite3/libsqlite -I/opt/source/php-src/ext/zip/lib -I/opt/source/php-src/TSRM -I/opt/source/php-src/Zend -I/usr/include -g -O2 -fvisibility=hidden -c /opt/source/php-src/ext/tokenizer/tokenizer_data.c -o ext/tokenizer/tokenizer_data.lo
In file included from /opt/source/php-src/main/php.h:406:0,
from /opt/source/php-src/ext/tokenizer/tokenizer_data.c:26:
/opt/source/php-src/ext/tokenizer/tokenizer_data.c: In function ‘tokenizer_register_constants’:
/opt/source/php-src/ext/tokenizer/tokenizer_data.c:89:40: error: ‘T_CHARACTER’ undeclared (first use in this function)
REGISTER_LONG_CONSTANT("T_CHARACTER", T_CHARACTER, CONST_CS | CONST_PERSISTENT);
^
/opt/source/php-src/Zend/zend_constants.h:43:103: note: in definition of macro ‘REGISTER_LONG_CONSTANT’
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name), (lval), (flags), module_number TSRMLS_CC)
^
/opt/source/php-src/ext/tokenizer/tokenizer_data.c:89:40: note: each undeclared identifier is reported only once for each function it appears in
REGISTER_LONG_CONSTANT("T_CHARACTER", T_CHARACTER, CONST_CS | CONST_PERSISTENT);
^
/opt/source/php-src/Zend/zend_constants.h:43:103: note: in definition of macro ‘REGISTER_LONG_CONSTANT’
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name), (lval), (flags), module_number TSRMLS_CC)
^
/opt/source/php-src/ext/tokenizer/tokenizer_data.c:90:44: error: ‘T_BAD_CHARACTER’ undeclared (first use in this function)
REGISTER_LONG_CONSTANT("T_BAD_CHARACTER", T_BAD_CHARACTER, CONST_CS | CONST_PERSISTENT);
^
/opt/source/php-src/Zend/zend_constants.h:43:103: note: in definition of macro ‘REGISTER_LONG_CONSTANT’
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name), (lval), (flags), module_number TSRMLS_CC)
^
/opt/source/php-src/ext/tokenizer/tokenizer_data.c: In function ‘get_token_type_name’:
/opt/source/php-src/ext/tokenizer/tokenizer_data.c:228:8: error: ‘T_CHARACTER’ undeclared (first use in this function)
case T_CHARACTER: return "T_CHARACTER";
^
/opt/source/php-src/ext/tokenizer/tokenizer_data.c:229:8: error: ‘T_BAD_CHARACTER’ undeclared (first use in this function)
case T_BAD_CHARACTER: return "T_BAD_CHARACTER";
^
make: *** [ext/tokenizer/tokenizer_data.lo] Error 1
root@patrick:/opt/source/php-src#
设置
- Ubuntu 14.04.3 x64
- 8gb RAM
- 英特尔i5
如果你需要更多信息,请在投票前告诉我。
谢谢。
我在Ubuntu 14上编译PHP 5.6.30
时遇到了同样的错误,并决定继续执行。事实证明,我使用的是一个不受支持的GNU Bison版本。Ubuntu 14.04提供了Bison版本3.x.x
。事实证明,PHP5仅支持Bison 2.4及以上版本(但不大于或等于3.x.x
)。我还没有找到确切的来源来支持这一说法。然而,我相信我的结论是合理的,基于反复试验。
为了在Ubuntu 14.04上编译PHP 5.6,我从Launchpad下载了Bison 2.5。查找您的机器的体系结构并下载相应的.deb
档案。提取某些目录下包的数据部分的内容,如下所示:
$ ar x bison_2.5.dfsg-2.1_ARCH.deb
$ tar xf data.tar.gz
现在,您需要指向配置脚本,以便在配置构建时使用该版本的Bison。为此,请将PATH
变量设置为自定义Bison二进制文件位置的第一个点(注意:数据存档扩展到提取目录下的./usr/bin/bison
):
$ PATH=/path/to/extraction/usr/bin:$PATH ./configure ...
您应该在输出中看到以下内容:
checking for bison... bison -y
checking for bison version... 2.5 (ok)
现在试试make
。如果结果和我的一样,它应该正确构建。
有趣的是,在使用Bison3之前,我已经构建了PHP 7.0.9
,它运行得很好。我倾向于认为这只是PHP 5构建的一个限制。