Add .so as php extension
Asked Answered
P

1

7

I have a .so file generated with SWIG. I would like use the functions defined there as a php extension. How do I add them as a php extension?

I added the .so to the extensions directory, and in php.ini added a line: "extension=example.so", then restarted apache.

Still when I run: php -d "extension=example.so" -m, it does not appear as an extension, and says: "Unable to load dynamic library '/usr/lib/php5/...../example.so. cannot open shared object file: Permission denied in Unknown on line 0"

Yet, permissions are 777

Permisions

permissions

PHP .so folder

extensions folder

php.ini file

php.ini file enter image description here

checking for extension [checking for extension[5]

Extension "example.so" not there.

Parrot answered 16/2, 2016 at 19:31 Comment(5)
is your extension_dir correct? is command-line php using the right php.ini?Gully
1. it is in the correct directory. 2. I added the extension to the /cli/ php.ini. I just noticed, php -d "extension=xxxxx.so, says: Unable to load dynamic library '/usr/lib/php5/...../xxxxx.so. cannot open shared object file: Permissino denied in Unknown on line 0Parrot
modify the permissions of your .so then :) chmod 755 {so}Gully
What about the directory it's in?Gully
@ also set to 777. I added pictures to show the state of affairsParrot
P
5

Solved by adding the full path of the .so to the php.ini

extension=/full/path/to/so/example.so

Therefore, adding the .so to the php extensions folder is unnecessary. The .so may reside in any directory.

Parrot answered 16/2, 2016 at 20:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.