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" 
可以使用批处理简化此命令:
msdev %1 /MAKE "%2 - Win32 Release_TS"
%1%2对应参数1参数2,保存make.bat文件名。然后将路径加入到系统环境,就可以进入ext目录使用
make myhello\myhello.dsp myhello 进行编译了,这里的myhello是你的项目名


编译中遇到的问题如下:

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"

问题至此解决。





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值