php-ffi
php-ffi copied to clipboard
do it work with custom lib ?
hello , can it bu used with custom random lib ? i have it working with default .so proved in debian buster (libc.so for example ) but every try with a custom lib like nvapi.dll.so result with "Failed loading 'xxxx.so' in" file.php
it is normal ?
FFI can be used with any arbitrary library, subject to the limitations outlined in the documentation for FFI::load()
/FFI::cdef()
. There are a huge number of potential causes for a failure to load a library, but the most likely causes of your issue are either:
- The header file you are using requires preprocessing before it can be used. FFI does not (currently) interpret preprocessor directives (such as
#include
,#define
,#if
etc) and any set of declarations which depends on external symbols or macro interpretation will not be valid. - The path of the library you are trying to load is not correct. As stated in the documentation, any non-system library must specify a path to the library, you cannot just supply the name. In fact, libraries are loaded via
dlopen()
(orLoadLibraryW()
on Windows), as such it is subject to the same behaviour as documented those routines.