Search code examples
phpc++dllphp-extensionphp-internals

How do I compile a PHP extension with Microsoft Visual C++ 2008?


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().

When I try to test the function (a simple double() function) it obviously does not work. I used this tutorial).

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.

System Specs

OS: Windows (Vista)
Server: WAMP
PHP: 5.3.5 (Xampp and IIS also installed)

When I run the command php --ini i get this error:

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?


Solution

  • Solution from the comments...

    -I found the solution forums.zend.com/viewtopic.php?f=55&t=2045

    -Possible duplicate: question: stackoverflow.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)

    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.