3

After compiling my own php extension using VC9 (2008) and VC10 (2010) using the next steps:

http://blog.slickedit.com/2007/09/creating-a-php-5-extension-with-visual-c-2005/

I get the next error when initializing php:

PHP Warning:  PHP Startup: FirstPHPExt Module: Unable to initialize module
Module compiled with build ID=API20090626,TS
PHP    compiled with build ID=API20090626,TS,VC9
These options need to match
 in Unknown on line 0

Why it doesn't says that I compiled the module with VC9?

More info:

Operating System: Windows7 x64 PHP: 5.3.3,TS,VC9

Artefacto
  • 96,375
  • 17
  • 202
  • 225
Wiliam
  • 3,714
  • 7
  • 36
  • 56

3 Answers3

10

Ok, I found the solution:

You must add a preprocessor constant into php-src/Zend/zend_build.h:

#define PHP_COMPILER_ID "VC9"

And it will work.


Solution found here: http://forums.zend.com/viewtopic.php?f=55&t=2045

Wiliam
  • 3,714
  • 7
  • 36
  • 56
  • In your case it was the compiler version, but note that sometimes one of the other segments of the build ID may be the problem. If the API is different, then you compiled against another (incompatible) PHP version than you're deploying the extension to. And finally, if TS/NTS are not matching, then you need to either define or undefine the `ZTS` preprocessor definition in your extenstion project to match that of PHP. (TS=Thread-Safe, NTS=Non-Thread-Safe). – Alexander Tobias Bockstaller Oct 22 '14 at 13:58
2

The official documentation for building PHP and extensions is in the wiki.

You should create a config.w32 file to your extension and build it through the command line. That's the method that's officially supported.

Artefacto
  • 96,375
  • 17
  • 202
  • 225
0

And it is strongly recommended to use the same CRT (VC9) than php itself. There are known issues when mixed CRTs are used between apache, php or its extensions.

Pierre
  • 716
  • 4
  • 10
  • It's true, but under VS2010 you can link against vc9 crt. Worth a try – Stef Jan 07 '12 at 09:51
  • Is it only a UI option or is there some linker options to do it? I can't find the doc on possible flags to vc10 to link against vc9 crt. – Pierre Feb 27 '12 at 09:51
  • Into "Properties" of your project, "Configuration properties", General, you must change "Platform Toolset" – Stef Feb 28 '12 at 10:37