Are there kotlin bindings for libffi?
# kotlin-native
m
Are there kotlin bindings for libffi?
l
Nothing ready-made I think. But I just included it using cinterop and it was very easy.
I then created a higher level FFI that calls into either Kotlin native using libffi or using the new
java.lang.foreign
for JVM.
m
That is pretty much what I wanted to do, do You have some sample code available for the setup that You can share?
l
There is a linux and a JVM backend (the latter requiring Java 21)
It's a work in progress, so it may be a bit messy, but at least it should be able to give you some inspiration.
m
Thank You very much!
l
No problem. I hope it helps.
I just found a mistake in my project. The cinterop file for libffi is in the wrong module (I forgot to copy it when I moved ffi-mod to its own module). You can find it here: https://codeberg.org/loke/array/src/branch/master/array/src/nativeInterop/cinterop/libffi.def It builds because
ffi-mod
depends on
array
, but it's a bit ugly. I'll fix it.
Fixed
🙌 1