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 ¶ms)
{
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.
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.