Compiling a php extension with Visual Studio 2008, MODULE ID don't match with php
Asked Answered
H

3

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

Hangup answered 4/9, 2010 at 9:56 Comment(0)
H
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

Hangup answered 4/9, 2010 at 10:8 Comment(1)
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).Overcoat
S
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.

Scad answered 4/9, 2010 at 22:38 Comment(0)
O
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.

Obstinate answered 9/7, 2011 at 2:9 Comment(3)
It's true, but under VS2010 you can link against vc9 crt. Worth a tryCrossley
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.Obstinate
Into "Properties" of your project, "Configuration properties", General, you must change "Platform Toolset"Crossley

© 2022 - 2024 — McMap. All rights reserved.