使用 Visual Studio 2008 在 Windows 上编译我自己的 PHP 扩展
我写了一个PHP扩展,在linux下可以成功编译运行。 但在Windows上,我遇到了一些问题。
这是 PHP 扩展源代码,http://www.bluefly.cn/xsplit.tar。 gz ,并且在 Linux 上运行良好。 但我也想让它在 Windows 上运行。
抱歉,我不是专业人士,所以我希望有人可以帮助我。
感谢任何帮助并提前致谢~
I wrote a PHP extension and it could be compiled and run under linux successfully. But on windows, I met some problems.
I did the compiling on windows according to http://blog.slickedit.com/?p=128 with PHP source version 5.2.10, and after the compiling it generated the dll file. But when I tried to use the dll file, it reported me the memory problems when starting Apache(Wamp server). And then I started the debugging process, it seemed that REGISTER_INI_ENTRIES() had problems.
Here is the PHP extension source code, http://www.bluefly.cn/xsplit.tar.gz , and it works fine on Linux. But I also want to make it work on Windows.
Sorry I am not a pro so that I hope someone can help me.
Any help is appreciated and thanks in advance~
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在 Linux 上没有看到问题的原因很可能是您在 Windows 上进行线程安全构建,而不是在 Linux 上进行。 尝试在 Linux 上添加
--enable-maintainer-zts
,然后使用 valgrind 进行检查 (USE_ZEND_ALLOC=0 valgrind /usr/bin/php script.php
)我发现您没有定义初始化线程变量的
php_xsplit_init_globals
。 该函数必须通过添加调用从 MINIT 注册。 也许还有其他问题,但这是我看到的第一件事。
The reason you're not seeing an issue on Linux is most likely that you're doing a thread safebuild on windows, but not on Linux. Try adding
--enable-maintainer-zts
on Linux and then check using valgrind (USE_ZEND_ALLOC=0 valgrind /usr/bin/php script.php
)From a quick glanceover your code I saw that you didn't define your
php_xsplit_init_globals
which initialized thread variables. Tis function has to be registered fromMINIT
by adding acall. Maybe something else is wrong, but that's the first thing I saw.
Wamp 使用 VC6 编译,它要求您的模块使用 VC6 编译。
报道 Romain Bourdon(WampServer 的作者)的话:因为 Apache 是用 VC6 编译的,所以如果你想将 PHP 作为模块运行(如在 WampServer 中),你必须用 VC6 编译该模块。
如果您想使用更新的平台编译模块,则必须编译整个 PHP-CGI 发行版并将其作为(快速)CGI 运行。
如果您可以阅读法语(或者如果您知道如何使用翻译器),您可以阅读 这篇文章。
Wamp is compiled using VC6 and it requires your module to be compiled with VC6.
Reporting Romain Bourdon (author of WampServer) words : Because Apache is compiled with VC6, if you want to run PHP as a module (as in WampServer) you must compile the module with VC6.
If you want to compile your module with a more recent platform, you have to compile your entire PHP-CGI distribution and run it as a (fast-)CGI.
If you can read french (or if you do know how to use a translator) you can read this post.