FFI::cdef() fails with a cryptic error when a shared library is missing, and the
same library is named differently on each operating system (libvulkan.so.1,
vulkan-1.dll, libvulkan.1.dylib). This package finds the library before you
load it, the way the dynamic linker of the operating system searches it, so you
can check that it is installed, pick the name that exists and report a clear error.
composer require ffi/locationRequires PHP 8.1 or later.
use FFI\Location\Locator;
$pathname = Locator::resolve('libvulkan.so.1', 'vulkan-1.dll', 'libvulkan.1.dylib')
?? throw new RuntimeException('Vulkan is not installed');
$vulkan = FFI::cdef($header, $pathname);The search order on each system, the options and the limitations are described in the documentation.