php-vips: FFI\Exception : Failed loading 'libvips.so.42' after upgrade to v2

Hello,

I’ve just upgraded a PHP 8.1 app from v1 to v2 and am now getting the following exception:

FFI\Exception : Failed loading 'libvips.so.42'
.../vendor/jcupitt/vips/src/Config.php:310
.../vendor/jcupitt/vips/src/Config.php:195
.../vendor/jcupitt/vips/src/Config.php:259
.../vendor/jcupitt/vips/src/Image.php:712

I’ve enabled FFI like so:

FFI support => enabled

Directive => Local Value => Master Value
ffi.enable => On => On
ffi.preload => no value => no value

I also removed the vips php extension, libvips is on version 8.12.2 and was installed via Homebrew.

I’d appreciate any pointers when you find some time. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 28 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@andrefelipe oh sweet! That’s a good find! I’ll patch it. Sorry, I should have spotted that the libname was wrong.

Yes, direct loading of the library should be MUCH better than that binary extension. I’m hoping it’ll save a lot of people a lot of trouble.

Found it!!!

PHP_OS_FAMILY constant is “Darwin” in my case (not sure about “OSX”)

So at “Config.php” file I changed the libraryName function to be:

private static function libraryName($name, $abi)
    {
        switch (PHP_OS_FAMILY) {
            case "Windows":
                return "$name-$abi.dll";

            case "OSX":
            case "Darwin":
                return "$name.$abi.dylib";

            default:
                // most *nix
                return "$name.so.$abi";
        }
    }

It should just work with current php-vips. I bought an M2 mac mini and pasted some extra code in. With homebrew libvips, no config should be necessary.