Unable to open library 'libvips-42.so'. Make sure that you've installed libvips and that 'libvips-42.so' is on your system's library search path.
vral-parmar opened this issue ยท 17 comments
Hello,
i try php-vips with laravel and getting following error, i try googling but it seems like its bug maybe, can anyone please give some solution on that.

i tried troubleshoot using setting path but its not working again.

i also try changing my php.ini but its still hang on same error.
i also try it with different OS like mac, Window, Linux, but getting a same error.
linux
Unable to ope library 'libvips-42.so'. Make sure that you've installed libvips and that 'libvips-42.so' is on your system's library search path.
window
Unable to ope library 'libvips-42.dll'. Make sure that you've installed libvips and that 'libvips-42.dll' is on your system's library search path.
mac
Unable to ope library 'libvips-42.dylib'. Make sure that you've installed libvips and that 'libvips-42.dylib' is on your system's library search path.
My configuration is:
OS: Ubuntu 24.04 LTS
php : 8.3.11
laravel : 11x
vips : 8.15.1
composer : 2.7.7
Hi, I had the same issue. The solution for me was to set ffi.enabled=true in my php.ini file
i checked, its already enabled in my ini.
[...] 'libvips-42.so' [...]
[...] 'libvips-42.dylib' [...]
Are you sure it looks for these libraries? On Unix it should look for libvips.so.42 and on macOS it should look for libvips.42.dylib.
right @kleisauke but didnt get any resolution.
What's the output of the following commands?:
$ php --ri ffi
$ php -r "var_dump(ini_get('ffi.enable'));"
$ php -r "var_dump(extension_loaded('ffi'));"
$ vips --versionAre you testing this with PHP-FPM?
@vral-parmar please do NOT cross-post.
These projects are maintained by unpaid volunteers and asking the same question in many places just makes more unnecessary work for them. Now I have to go to your stackoverflow questions and post comments sending people here.
@jcupitt Thanks for sharing your thoughts, i removed content from other platforms, hope i get solution here.
@kleisauke vips version im using is vips-8.15.1, i also tried with 8.16 returning same error.
Please share the complete output of those PHP commands. For example with a default PHP installation, I see:
$ php --ri ffi
FFI
FFI support => enabled
Directive => Local Value => Master Value
ffi.enable => preload => preload
ffi.preload => /usr/share/php/preload/*.h:/usr/local/share/php/preload/*.h => /usr/share/php/preload/*.h:/usr/local/share/php/preload/*.h
$ php -r "var_dump(ini_get('ffi.enable'));"
Command line code:1:
string(7) "preload"
$ php -r "var_dump(extension_loaded('ffi'));"
Command line code:1:
bool(true)i.e. ffi.enable is preload by default, which won't work with php-vips, it needs to be set to true.
Line 49 in a8cc66c
Hello @kleisauke following are the output of given commands.
$ php --ri ffi
FFI
FFI support => enabled
Directive => Local Value => Master Value
ffi.enable => preload => preload
ffi.preload => no value => no value
$ php -r "var_dump(ini_get('ffi.enable'));"
string(7) "preload"
$ php -r "var_dump(extension_loaded('ffi'));"
bool(true)
am i missing something?
The solution for you will be the same as @TomasHermanek posted in the first comment or @kleisauke above.
#251 (comment)
#251 (comment)
Try to set ffi.enable in php.ini to true. Your value is preload, not true.
The error about not enabled ffi globally is somehow hidden behind Unable to open libary...
Hi @stankolubomir
here is my ini config

in php 8.3 i guess dynamic loading is not supported for that i need to rebuild php manually which open too many security concerns.

is there any other way around?
Thanks for the direction @jcupitt
$ php --ini
Warning: FFI Parser: unexpected character '\177' at line 1
in Unknown on line 0
Warning: FFI: failed pre-loading '/usr/lib/php/20230831/ffi.so' in Unknown on line 0
Fatal error: Unable to start FFI module in Unknown on line 0
i also try to reinstall ffi using.
sudo apt-get install --reinstall php-ffi
and
sudo apt-get update
sudo apt-get install php-ffi
@vral-parmar Do you have libffi8 package installed?
sudo apt-get install libffi8
@stankolubomir here is the output.
$ sudo apt-get install libffi8
[sudo] password:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libffi8 is already the newest version (3.4.6-1build1).
libffi8 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
its already installed.
Please remove ffi.preload=/usr/lib/php/20230831/ffi.so from your php.ini. You only need to include the following settings:
zend.max_allowed_stack_size=-1
ffi.enable=trueNote that in most Linux distributions, FFI is enabled by default in PHP (see e.g. /usr/share/php8.3-common/common/ffi.ini on Ubuntu 24.04). Therefore, you should probably also remove extension=ffi from your php.ini.
I hope this information helped. Please feel free to re-open with more details if further assistance is required.