php-ffi icon indicating copy to clipboard operation
php-ffi copied to clipboard

do it work with custom lib ?

Open Noext opened this issue 5 years ago • 1 comments

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 ?

Noext avatar Nov 20 '19 13:11 Noext

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() (or LoadLibraryW() on Windows), as such it is subject to the same behaviour as documented those routines.

DaveRandom avatar Apr 21 '20 04:04 DaveRandom