如何在Windows上为PHP7.0编译PECL扩展win32service

时间:2016-12-13 11:05:21

标签: php c pecl

我尝试从https://pecl.php.net/package/win32service

编译pecl扩展程序win32service

在上面的pecl页面上,只有PHP5.5和PHP5.6的版本可用。所以我试着自己编译它。由于PHP7.0在我的环境中正常运行,因此我收到了一些链接器错误。

Creating library C:\php-sdk\phpdev\vc14\x64\php-7.0.14-src\x64\Release_TS\php_win32service.lib and object C:\php-sdk\phpdev\vc14\x64\php-7.0.14-src\x64\Release_TS\php_win32service.exp
win32service.obj : error LNK2019: unresolved external symbol Z_TYPE_PP referenced in function svc_thread_proc
win32service.obj : error LNK2019: unresolved external symbol Z_STRVAL_PP referenced in function svc_thread_proc
win32service.obj : error LNK2019: unresolved external symbol Z_STRLEN_PP referenced in function svc_thread_proc
win32service.obj : error LNK2019: unresolved external symbol Z_LVAL_PP referenced in function svc_thread_proc
C:\php-sdk\phpdev\vc14\x64\php-7.0.14-src\x64\Release_TS\php_win32service.dll : fatal error LNK1120: 4 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\link.exe"' : return code '0x460'
Stop.

使用的配置(Windows 7,x64,TS,VC14,PHP7.0.14):

  

configure --disable-all --enable-cli --enable-win32service = shared

如何构建该扩展或如何修复代码以进行链接?

2 个答案:

答案 0 :(得分:1)

我收到了维护人员的一条说明,指出了根本原因所在的某个方向。非常感谢Richard。

扩展必须从PHP(5.x.x)改编为PHPNG(7.x.x)。 内部已经改变,宏(例如Z_TYPE_PP)不再存在。

文档https://wiki.php.net/internals/engine/objects说:

  

可以使用Z_TYPE()或Z_TYPE_P()宏读取zval的类型,使用Z_TYPE_FLAGS()或Z_TYPE_FLAGS_P()类型标记,类型和标志的组合 - Z_TYPE_INFO()或Z_TYPE_INFO_P()。 PHPNG不适用于指向zval的指针,它不再提供带有_PP()后缀的宏(如Z_TYPE_PP)。

所以这意味着扩展的代码必须被重构/重写,因为宏已经消失,正如您在PHP代码本身中看到的那样:

PHP5.6:http://lxr.php.net/source/xref/PHP-5.6/Zend/zend_operators.h#491

PHP7.0:http://lxr.php.net/source/xref/PHP-7.0/Zend/zend_types.h#337

<强>更新 由于我的问题,在该扩展中已经做了很多工作。有几个工作的realeases甚至dll被上传到pecl页面: https://pecl.php.net/package/win32service

答案 1 :(得分:1)

我为PHP-7.0和PHP-7.1构建php_win32service: https://github.com/fawno/pecl-system-win32service/releases https://github.com/alpha/win32service/releases

更新: macintoshplus正在更新https://github.com/InExtenso/win32service中的extensión 他需要帮助才能成为包装的佼佼者: https://github.com/InExtenso/win32service/issues/4