Please give a brief summary of your issue:
PHP SDK setup failing - libPDFNetC.so: cannot open shared object file
Please describe your issue and provide steps to reproduce it:
Followed all the steps that are mentioned here. Steps for SWIG were not available though in the Getting Started section though.
Full error:
/home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so’ (tried: /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so (libPDFNetC.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so (/usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so: cannot open shared object file: No such file or directory))
Had tried the steps in the troubleshooting section. None of them helped. enable_dl is turned on.
To ensure we’re on the same page, can you help us understand what is in your current working directory where you are trying to build the PHP bindings? Particularly, if you could run this command in the directory where the PHP build is being done:
ls -lh .
I’d expect the directories originating from PDFNetC64/Headers and PDFNetC64/Lib/ to be there, per steps 3 and 4 of our guide:
May I also ask what command you ran to trigger the full error you provided? I’d be happy to provide further guidance once I have a better understanding of the current situation.
Thanks for providing all the information that you have, I am in the process of setting up my environment to try and replicate this issue, but in the meantime, may I ask if inside of the directory /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/ (i.e. where PDFNetPHP.so resides), is libPDFNetC.so also in that directory? If not, can you try copying the libPDFNetC.so dynamic library into /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/ to see if then PDFNetPHP.so is able to resolve this issue:
/home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so (libPDFNetC.so: cannot open shared object file: No such file or directory)
In the meantime, I will let you know once I’ve had a chance to try and replicate this issue, but please let me know what the results of my above suggestion are in the meantime when you have a moment.
@Correy_Lim
As noticeable in my previous comment, the libPDFNetC.so is in the expected location.
Do let me know if in addition to my previous comment any new info is required.
One thing I do notice in your directories is that the .so files are owned by the root user. Could you please ensure that they can be accessed by the user that is running the PHP application (for example, like www-root, or http).
I am still working on creating a PHP build in a similar environment as yours, and I will get back to you as soon as I have completed this work, but if you could try Shakthi’s recommendation in the meantime and let us know the results, it would be greatly appreciated!
nik@DESKTOP-B3CS5F7:~/PDFTron/PDFNetWrappers/PDFNetC/Lib$ php -a
PHP Warning: PHP Startup: Unable to load dynamic library '/home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so' (tried: /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so (libPDFNetC.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so (/usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Interactive mode enabled
Apologies for the delayed response, I was indeed working on trying to reproduce this and I was getting close to finishing the build and being able to run PHP sample code with our library, but was side-tracked by other urgent matters, but I have time to get back to this today, so I will get back to you soon today.
I took a look at the latest error you reported again here:
PHP Warning: PHP Startup: Unable to load dynamic library '/home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so' (tried: /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so (libPDFNetC.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so (/usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
It is PDFNetPHP.so and not PDFNetPHP.so.so. Could this be the problem? Is the absolute path to PDFNetPHP.so perhaps incorrectly written as PDFNetPHP.so.so in your php.ini file?
Had a similar question as you had. However, after reinspecting the error, realized that it is PHP’s mechanism to look for the extension at different possible places. First it looks for the extension at /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so
and then at /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so
I assume this is to support the use-case where someone might miss entering .so in the php.ini file.
The steps for setting up the SDK stated that SWIG needs to be installed. However, since the steps to do the same were missing, had installed it myself with some research on Google. Here are the version numbers of both PHP and SWIG:
nik@DESKTOP-B3CS5F7:/mnt/c/Users/syste$ swig -version
SWIG Version 3.0.12
Compiled with g++ [x86_64-pc-linux-gnu]
Configured options: +pcre
Please see http://www.swig.org for reporting bugs and further information
nik@DESKTOP-B3CS5F7:/mnt/c/Users/syste$ php -v
PHP Warning: PHP Startup: Unable to load dynamic library '/home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so' (tried: /home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so (libPDFNetC.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so (/usr/lib/php/20190902//home/nik/PDFTron/PDFNetWrappers/PDFNetC/Lib/PDFNetPHP.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.24 (cli) (built: Sep 23 2021 21:35:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.24, Copyright (c), by Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
Not sure what’s failing here. The relatively complex part of the setup, building the so file, appears to be complete. But the usage of the extension is failing.
Thank you for your response. Just to confirm, were you able to run the samples at all by calling the RunTest.sh batch to confirm if the module loads properly? I see now you are just getting this message as a warning when you run PHP in interactive mode.
Great idea @shakthi124. Finally a way out of what seemed to be going nowhere.
Will experiment more with the tests and let you know. Ran one of the tests and for some cases it printed ‘Done’. So assuming it is working.
Not sure as to why no warning was printed, probably it is suppressed in the test files. The warning from PHP regarding library load failure is at best misleading.