0%

linux 下 制作PHP扩展出现的问题 Module compiled with module API=xx[转]

制作出.so 文件后,php -v 出现下面的提示

PHP Warning: PHP Startup: checkcode: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20131226
These options need to match

in Unknown on line 0
PHP Warning: PHP Startup: taint: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20131226
These options need to match
in Unknown on line 0
PHP 5.6.10 (cli) (built: Jul 2 2015 13:26:19)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

在网上http://www.th7.cn/Program/php/201408/253791.shtml 看到说是 debug和release 的问题,很是怀疑。
猜测:应该是运行的php和实现的插件版本不统一的问题
但是是在php源代码基础上构建的插件,问题出现在哪里呢?

使用idapro 分析 so文件发现 20090626 在so文件内,那就说明被什么文件带入了so文件中,在生成的插件框架文件中 .c 找不到这个串的定义,一定处在include 文件中,那么在哪里?

原来:机器上有php,后来下载源码编译,然后产生插件。是否这个插件的编译使用了原php的头文件呢?
:在Makefile中发现
INCLUDES = -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
使用的的确是原来安装的php版本

20090626 这个串在 Zend_modules.h 中
/usr/include/php/Zend 这个目录下
定义为:
#define ZEND_MODULE_API_NO 20090626
而在源码中:
#define ZEND_MODULE_API_NO 20131226

正因为此,所以php和它的插件不配对,不能初始化
附:

#define PHP_5_0_X_API_NO 220040412
#define PHP_5_1_X_API_NO 220051025
#define PHP_5_2_X_API_NO 220060519
#define PHP_5_3_X_API_NO 220090626
#define PHP_5_4_X_API_NO 220100525
#define PHP_5_5_X_API_NO 220121212
#define PHP_5_6_X_API_NO 220131226

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!