Re: PHP FFI oddity
| From: | Christoph M. Becker | Date: | Fri, 03 Jan 2020 09:30:47 +0000 |
| Subject: | Re: PHP FFI oddity | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326977@lists.php.net to get a copy of this message | ||
On 02.01.2020 at 22:38, Larry Garfield wrote:
> This is a long shot, but I figured I'd try here before PHP-Internals.
>
> I'm experimenting with PHP-FFI. 2 weeks ago, I had working code. The same code 2 weeks
> later is now not working. (I say "Same code" because I can confirm that via Git.
> It's not just me saying I didn't touch it.)
>
> The code in question is here:
>
> https://github.com/Crell/ffi-test/tree/master/points
>
> Running
make inline (to test loading up the FFI logic inline)
> works.
>
> Running make preload (to load the library in a preload routine)
> fails.
>
> Specifically, the preloader.php script is called, and gives this error:
>
> PHP Warning: failed pre-loading '/home/crell/temp/php-ffi-test/points/points.h',
> cannot resolve C function 'distance' in preloader.php on line 6
>
> Line 6 is:
>
> FFI::load(__DIR__ . "/points.h");
>
> I do not understand how this worked before, but doesn't now. A friend suggested some
> library version or path changed, but I've no idea what.
>
> The "dummy" example (in a separate folder) works fine. It's straight out of the
> PHP manual. The main difference is it's linking against stdlib, whereas
> points has a tiny custom library. That's being problematic.
>
> Anyone have a recommendation here? I'm out of ideas.
Would it work if you used an absolute path in points.h? If so, I think
LD_LIBRARY_PATH would need adjustment.
--
Christoph M. Becker