php扩展编译nts的方法

最近编译一个扩展遇到很多问题,始终不成功。经过反复不断的尝试各种方法,终于解决了。

编译完扩展测试执行测试文件出现下面提示

[root@localhost sample]# /home/php7/bin/php sample.php 

Warning: dl(): sample: Unable to initialize module
Module compiled with build ID=API20151012,TS
PHP    compiled with build ID=API20151012,NTS
These options need to match
 in /home/xiongweixing/php-7.0.21/ext/sample/sample.php on line 5
Functions available in the test extension:

Warning: Invalid argument supplied for foreach() in /home/xiongweixing/php-7.0.21/ext/sample/sample.php on line 10

查看提示觉得可能是ts、nts的问题。

php默认是ts模式,使用nts需要加上下面参数

configure –enable-cli –disable-zts

重新编译扩展再测试运行成功了

[root@localhost sample]# /home/php7/bin/php sample.php 
Functions available in the test extension:
confirm_sample_compiled
sample_hello_world

Congratulations! You have successfully modified ext/sample/config.m4. Module sample is now compiled into PHP.

你可能感兴趣的:(php扩展开发,php-nts)