dpv46227 2019-04-03 06:29
浏览 125

加载我构建的PHP模块失败,没有错误

I built my hello_world php module by following tihs: https://zando.io/post/hello-world-php-7-extension/

And I successfully built a hello.so under modules/

But when I tried to load this hello.so, it failed.

(adding extension=hello.so to php.ini and put the .so file to extension_dir)

var_dump(extension_loaded('hello'));
var_dump(hello_world());

Output:

bool(false)
Fatal error: Uncaught Error: Call to undefined function hello_world() in /var/www/app/test.php(2) : eval()'d code:1 Stack trace: #0 /var/www/app/test.php(2): eval() #1 {main} thrown in /var/www/app/test.php(2) : eval()'d code on line 1

But when I tried to load my friend's hello_world so file, it works!!

(same source code, same building process...)

I really don't know why...

  • 写回答

1条回答 默认 最新

  • dtng5978 2019-04-03 10:36
    关注

    I have solved this problem.

    Because I use the wrong version of phpize and php-config.

    The phpinfo() shows that PHPAPI is 20170718

    But my original phpize shows 20180731

    So I reinstall the php7.2-dev.

    Then run phpize7.2 and then ./configure --with-php-config=/usr/bin/php-config7.2 to configure the settings.

    And it works!

    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了