php7 编译 win32ps 模块

碰到了很多问题 ,但最终都解决了,感觉不错。

1)下载 php source, php sdk, 以及 win32ps的源代码

2) 参照下面的连接进行编译。

https://wiki.php.net/internals/windows/stepbystepbuild

注意点:

a) 设置phpsdk_setvars.bat环境变量之前,设置vc 的环境变量。

  "D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64

b) 文章介绍的目录结构太深了,我这样的结构也是没有问题的。

SDK:D:\tool\php-sdk

php source: D:\proj\php-src

win32ps: D:\proj\pecl\win32ps-1.0.1

c) 加上 "=shared" 就可以编译 extension dll 了(要不就会直接静态连接到php)

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

3) 源代码的修改。

a) MAKE_STD_ZVAL 被php7 废除了。 所以,改成类似下面的语句

    // MAKE_STD_ZVAL(tms);
    zval tms_instance;
    tms = &tms_instance;

b) 运行时,加载extension 会出现 【PHP Startup: Invalid library maybe not a PHP library 】错误

在win32ps.c 加上下面的代码,重新编译

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef COMPILE_DL_WIN32PS
ZEND_GET_MODULE(win32ps)
#endif

参考:http://stackoverflow.com/questions/7283949/php-warning-php-startup-invalid-library-maybe-not-a-php-library

以上。