I created a PHP Hello World
extension DLL with Microsoft Visual C++ 2008. I have the right php.ini
(I know because when I enable and disable the gd2 extension, there is an effect), but when I load the extension it does not pop up under the Additional Modules in phpinfo()
.
我用Microsoft Visual c++ 2008创建了一个PHP Hello World扩展DLL。我有正确的php。ini(我知道,因为当我启用和禁用gd2扩展时,会产生效果),但是当我加载扩展时,它不会在phpinfo()中的其他模块下弹出。
When I try to test the function (a simple double()
function) it obviously does not work. I used this tutorial).
当我尝试测试这个函数(一个简单的double()函数)时,它显然不起作用。我使用本教程)。
If someone could supply their dll created when doing this (to see If mine's messed up or if it's my server) then I'd gladly test it.
如果有人可以提供在执行此操作时创建的dll(查看我的dll是否有问题或者它是我的服务器),那么我很乐意测试它。
System Specs
OS: Windows (Vista)
Server: WAMP
PHP: 5.3.5 (Xampp and IIS also installed)
操作系统:Windows (Vista)服务器:WAMP PHP: 5.3.5(也安装了Xampp和IIS)
If you want to test to see if it works for you then download here.
如果您想测试它是否适合您,请在这里下载。
When I run the command php --ini
i get this error:
当我运行php -ini命令时,我得到这个错误:
PHP Startup: TalkPHP Extension: Unable to initalize module
Module compiled with build ID=API20090626, TS, VC9.
PHP compiled with build IF=API20090626, TS, VC6.
These options need to match
Does this mean I have to use Version 9 to compile PHP?
这是否意味着我必须使用版本9来编译PHP?
3 个解决方案
#1
2
VC9 and VC6 builds are not compatible. You either have to compile your DLL with VC6 or get PHP binaries compiled with VC9 from their download page.
VC9和VC6构建不兼容。您要么使用VC6编译DLL,要么从下载页面获得使用VC9编译的PHP二进制文件。
If you are using Apache and mod_php you will also need a VC9 build of Apache to load the VC9 PHP, you can get those from apachehaus.com.
如果您正在使用Apache和mod_php,您还需要一个Apache的VC9构建来加载VC9 PHP,您可以从apachehaus.com获得这些。
#2
1
Solution from the comments...
解决方案的评论……
-I found the solution forums.zend.com/viewtopic.php?f=55&t=2045
我找到了解决方案。zend.com/viewtopic.php?
-Possible duplicate: question: *.com/questions/3641751/
可能重复:问题:*.com/questions/3641751/
I get these warnings
我得到这些警告
c:\wamp\bin\php\php-5.3.5src\zend\zend_build.h(19) : warning C4005: 'PHP_COMPILER_ID': macro redefinition c:\wamp\bin\php\php-5.3.5src\main\config.w32.h(189) : see previous definition of 'PHP_COMPILER_ID' 1>
c:\wamp\bin\php\php-5.3.5src\main\config.w32.h(189) : warning C4005: 'PHP_COMPILER_ID' : macro redefinition 1>
c:\wamp\bin\php\php-5.3.5src\zend\zend_build.h(19) : see previous definition of'PHP_COMPILER_ID'
I think it has to do with the fact that mine actually says compiled with VC9 and on the others it has nothing. (They're warnings but I think it's why it doesn't work)
我认为这与事实有关,我的说法是用VC9编译的,而在其他的上面,它什么都没有。(它们是警告,但我认为这就是为什么它不起作用)
Ok, did nothing more but just tried it but when I ran the extension it WORKED. I still got errors from php --ini but it ran and WORKED.
好吧,除了尝试之外什么都没做,但当我运行扩展时,它成功了。我仍然有来自php ini的错误,但是它运行并工作了。
#3
0
I compiled and run successfully a custom php extension.
我编译并成功运行了一个自定义php扩展。
Can you try the following:
你能试试下面的方法吗?
- get the vc9 build from php-5.3.5
- 从php-5.3.5获得vc9构建
- don't #define PHP_COMPILER_ID in the zend_build.h header file (IMHO that's a bad idea anyway)
- 不要在zend_build中定义php_compile er_id。h头文件
- you probably defined PHP_COMPILER_ID in config.w32.h, too; remove it
- 您可能在config.w32中定义了php_compile er_id。h;删除它
- in your project settings (C/C++ - Preprocessor) define: PHP_COMPILER_ID=\"VC9\" (if you need the vc6 build of php then I would try to define PHP_COMPILER_ID=\"VC6\"; I don't know whether this works without problems but I've used the constellation [php-5.2.x vc6, custom php extension compiled with vc9] without problems, ever)
- 在您的项目设置(C/C+ -预处理器)中定义:php_compiler er_id = "VC9\"(如果您需要vc6构建php,我将尝试定义php_compile er_id =\“vc6 \”;我不知道这是否能正常工作,但我使用了constellation [php-5.2]。x vc6,用vc9编译的自定义php扩展,从来没有问题)
#1
2
VC9 and VC6 builds are not compatible. You either have to compile your DLL with VC6 or get PHP binaries compiled with VC9 from their download page.
VC9和VC6构建不兼容。您要么使用VC6编译DLL,要么从下载页面获得使用VC9编译的PHP二进制文件。
If you are using Apache and mod_php you will also need a VC9 build of Apache to load the VC9 PHP, you can get those from apachehaus.com.
如果您正在使用Apache和mod_php,您还需要一个Apache的VC9构建来加载VC9 PHP,您可以从apachehaus.com获得这些。
#2
1
Solution from the comments...
解决方案的评论……
-I found the solution forums.zend.com/viewtopic.php?f=55&t=2045
我找到了解决方案。zend.com/viewtopic.php?
-Possible duplicate: question: *.com/questions/3641751/
可能重复:问题:*.com/questions/3641751/
I get these warnings
我得到这些警告
c:\wamp\bin\php\php-5.3.5src\zend\zend_build.h(19) : warning C4005: 'PHP_COMPILER_ID': macro redefinition c:\wamp\bin\php\php-5.3.5src\main\config.w32.h(189) : see previous definition of 'PHP_COMPILER_ID' 1>
c:\wamp\bin\php\php-5.3.5src\main\config.w32.h(189) : warning C4005: 'PHP_COMPILER_ID' : macro redefinition 1>
c:\wamp\bin\php\php-5.3.5src\zend\zend_build.h(19) : see previous definition of'PHP_COMPILER_ID'
I think it has to do with the fact that mine actually says compiled with VC9 and on the others it has nothing. (They're warnings but I think it's why it doesn't work)
我认为这与事实有关,我的说法是用VC9编译的,而在其他的上面,它什么都没有。(它们是警告,但我认为这就是为什么它不起作用)
Ok, did nothing more but just tried it but when I ran the extension it WORKED. I still got errors from php --ini but it ran and WORKED.
好吧,除了尝试之外什么都没做,但当我运行扩展时,它成功了。我仍然有来自php ini的错误,但是它运行并工作了。
#3
0
I compiled and run successfully a custom php extension.
我编译并成功运行了一个自定义php扩展。
Can you try the following:
你能试试下面的方法吗?
- get the vc9 build from php-5.3.5
- 从php-5.3.5获得vc9构建
- don't #define PHP_COMPILER_ID in the zend_build.h header file (IMHO that's a bad idea anyway)
- 不要在zend_build中定义php_compile er_id。h头文件
- you probably defined PHP_COMPILER_ID in config.w32.h, too; remove it
- 您可能在config.w32中定义了php_compile er_id。h;删除它
- in your project settings (C/C++ - Preprocessor) define: PHP_COMPILER_ID=\"VC9\" (if you need the vc6 build of php then I would try to define PHP_COMPILER_ID=\"VC6\"; I don't know whether this works without problems but I've used the constellation [php-5.2.x vc6, custom php extension compiled with vc9] without problems, ever)
- 在您的项目设置(C/C+ -预处理器)中定义:php_compiler er_id = "VC9\"(如果您需要vc6构建php,我将尝试定义php_compile er_id =\“vc6 \”;我不知道这是否能正常工作,但我使用了constellation [php-5.2]。x vc6,用vc9编译的自定义php扩展,从来没有问题)