问题
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~
回答1:
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 from MINIT
by adding a
ZEND_INIT_MODULE_GLOBALS(xsplit, php_yplist_init_globals, NULL);
call. Maybe something else is wrong, but that's the first thing I saw.
回答2:
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.
来源:https://stackoverflow.com/questions/1036110/compiling-my-own-php-extension-on-windows-with-visual-studio-2008