hongmeigui22027 发表于 2017-3-27 11:39:46

window编译c开发的php扩展

php扩展在linux下面开发最是方便,对编译问题不用太头疼。但我现在工作使用的系统是window,只能在window下折腾。现在把window下面编译遇到的问题,做下记录。


有关在window下面使用C语言开发php扩展请参考下面博客:


http://koda.iteye.com/blog/315779


采用的编译工具vc6,个人比较喜欢使用命令行编译:
msdev myhello\myhello.dsp /MAKE "myhello - Win32 Release_TS"

  编译中遇到的问题如下:

1.缺少config.w32.h头文件


下载2个必要的包

http://www.php.net/extra/bindlib_w32.zip

http://www.php.net/extra/win32build.zip

把这2个包的内容放一起,解压缩到X:\win32build,X是你的硬盘分区。将X:\win32build\bin加入系统环境变量。
命令行输入:set path=%path%;X:\win32build\bin然后进入到php源码根目录执行buildconf.bat

提示:

Rebuilding configure.js

Now run 'cscript /nologo configure.js --help'
执行:cscript /nologo configure.js --with-php-build="../win32build" --without-libxml--disable-odbc


上面的参数务必补齐,不然出现一些错误也麻烦。等到

出现

Creating build dirs...

Generating files...

Generating Makefile

Generating main/internal_functions.c

Generating main/config.w32.h

Done.


config.w32.h就成功生成了

2.php_stream_transport.h 头文件报错,error如:

.\..\main\streams/php_stream_transport.h(85) : error C2143: syntax error : missing ')' before '*'

..\..\main\streams/php_stream_transport.h(85) : error C2081: 'socklen_t' : name in formal parameter list illegal


是由于找不到宏报的语法错误。打开这个文件,添加typedef int socklen_t,问题解决。


3.扩展加载错误,如图:


在php_stream_transport.h 里面加一行,定义PHP_COMPILER_ID="vc9"就把apache忽弄过去了。


#define PHP_COMPILER_ID "VC9"


问题至此解决。
页: [1]
查看完整版本: window编译c开发的php扩展