We help IT Professionals succeed at work.

PHP-CPP extension not loaded

Ludwig Diehl
Ludwig Diehl asked
on
Hi guys, I have recently installed php-cpp and compiled an extension. The thing is that the extension is created correctly (*.so) but the extension seems not to be loaded correctly as I cannot access any method from this ext.
I am using:
Centos 7.0.1406 64bits
nginx 1.6.2
php 5.4.16
g++ 4.8.2
Comment
Watch Question

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Did you create the 'ini' file in the extension directory to load it?  I believe they're in /etc/php.d/*.ini
Ludwig DiehlSystems Architect

Author

Commented:
Yes, I created the ini file and also copied the *.so to the extension dir
jkr
Top Expert 2012

Commented:
Do the log files shed in any light?
Top Expert 2015

Commented:
By default selinux will kill your module unless you label it correctly
see ls -z ; audit2allow ; semanage fcontext (respective manuals)
Ludwig DiehlSystems Architect

Author

Commented:
What do you mean by labeling it? Where should it be labeled?
Ludwig DiehlSystems Architect

Author

Commented:
By the way. SELinux is disabled in my server
Top Expert 2015

Commented:
Did you restart php-fpm after adding module? nginx does not load any php modules.
Threaded php module loaded by nginx will not load any additional modules.
Ludwig DiehlSystems Architect

Author

Commented:
I already tried restarting nginx and php-fpm but even after restarting both none of the modules I created using PHP-CPP load.
evilrixSenior Software Engineer (Avast)

Commented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Ludwig DiehlSystems Architect

Author

Commented:
I think enough information was given. I am still waiting for someone to help me solve this.
Top Expert 2015

Commented:
do you have a module loading directive in php.ini.d/*.ini ?
Top Expert 2015

Commented:
php-cpp module is broken, namely with php 5.4 (exact way you build with system compiler and system php-devel)
produces WRONG MODULE with missing symbols
namely here is a bug report:
https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/185
Which apparently is fixed for v1.3.3 or whatever follows 1.3.2
Ludwig DiehlSystems Architect

Author

Commented:
Thanks for answering. I tried compiling with latest version (1.4)  with not success. My Configuration is:

PHP/5.4.20
Zend Engine/2.4.0
Apache/2.4.6
gcc/4.8.1

The extension is created (*.so) but it is not loaded
Top Expert 2015

Commented:
So try last known working release according to bug report
Ludwig DiehlSystems Architect

Author

Commented:
I get this warning
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php5/extensions/myextension.so' - libphpcpp.so.1.4: cannot open shared object file: No such file or directory in Unknown on line 0

Open in new window

Top Expert 2015

Commented:
Run ldd command against "myextension.so"
Then "locate" all missing libraries, and add their path to  /etc/ld.so.conf.d/whatever.conf
Then run ldconfig
Systems Architect
Commented:
I found the cause of this problem. It was so simple!. I had to change the line
INSTALL_LIB = ${INSTALL_PREFIX}/lib

Open in new window

to
INSTALL_LIB=${INSTALL_PREFIX}/lib64

Open in new window

Then I compiled and installed phpcpp and bualá!
Ludwig DiehlSystems Architect

Author

Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for Ludwig Diehl's comment #a40800824

for the following reason:

It was clear that the problem had something to do with the file location so digging into paths gave me the answer
Top Expert 2015

Commented:
That was the last invented problem.... Initial problem was solved completely http:#40784050
Ludwig DiehlSystems Architect

Author

Commented:
Excuse me. Invented? What do you mean?. As you see the MAIN and ONLY problem was
PHP-CPP extension not loaded
By running "test.sh" included in phpcpp path I discovered this ID: 40800775 so I looked into Makefile and noticed and did this ID: 40800824
I don't know what do you mean by
Initial problem was solved completely
Top Expert 2015

Commented:
You can post a fix to php-cpp project (as a bug report)
They dont look like testing on exact system in bug report....
Ludwig DiehlSystems Architect

Author

Commented:
Yes, that would be useful.
Top Expert 2015

Commented:
For suse it is /usr/lib64/php5... They must change ./configure script...
As much as I am concerned you can pick your points back...
Ludwig DiehlSystems Architect

Author

Commented:
Thanks for your concern either way.
Ludwig DiehlSystems Architect

Author

Commented:
It worked!