3

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.

1
  • 1
    do you have dynamic extension enabled? Do you run the script from cli? do you see your extension loaded if you run "php -i | grep skeleton"? Commented Jun 24, 2015 at 17:13

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but this is not a solution, problem still persists.
0

I was getting the same error until I saw this ticket on PHP-CPP's repo: https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/180

Turns out my issue was that I followed someone else's advice that I should replace the contents of the /zend/ dir (in the PHP-CPP lib) with the contents of PHP's source code (that I got from php.net).

Once I rolled back the contents of /zend/ to be the same as what PHP-CPP provides, the problem went away.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.