duanji2002 2014-12-31 10:14
浏览 105

无法执行简单的Hello World PHP扩展

I am trying to run simple Hello World PHP extension, but after make & install extension and when I want to run test script I am experiencing following issue:

P Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/skeleton.so' - /usr/lib/php5/20121212/skeleton.so: undefined symbol: _ZN3Php9ExtensionD1Ev in Unknown on line 0
/etc/php5/cli/conf.d/skeleton.ini

My main.cpp file:

#include <phpcpp.h>
#include <iostream>

void helloWorld (Php::Parameters &params)
{
    std::string name=params[0];
    std::cout<<"Hello "<<name<<"!"<<std::endl;
}

extern "C" {

    PHPCPP_EXPORT void *get_module() 
    {
        static Php::Extension extension("skeleton", "1.0");
        extension.add("helloWorld", helloWorld);
        return extension;
    }
}

And here is my test script:

<?php
echo helloWorld('Ben'); 

I have been inspired by this tutorial: http://www.sitepoint.com/getting-started-php-extension-development-via-php-cpp/

Could you help me with this one? Thanks in advance for your help.

  • 写回答

2条回答 默认 最新

  • duandeng7132 2014-12-31 20:18
    关注

    I'm not sure if this is the problem, but you should use:

    Php::out << "Hello " << name << "!" << std::endl;
    

    instead of

    std::cout << "Hello " << name << "!" << std::endl;
    

    std::cout produces some errors in my extensions.

    Vinicius

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图