Can I, in an easy way, use a native library when I...
# kotlin-native
a
Can I, in an easy way, use a native library when I’m using Kotlin Multiplatform? I have a C library that I’d like to use but as far as I can tell I would have to write a JNI layer anyway
o
Native programs compiled with Kotlin/Native can use C and Objective-C libraries directly, without any JNI or such, see https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md https://github.com/JetBrains/kotlin-native/blob/master/OBJC_INTEROP.md
a
@olonho Yeah, I know that. But I want to use a 3rd party C library in my multiplatform library
o
in theory, for Kotlin/JVM C interop tool could be used as well, but it's not of production quality for external consumption.
a
@olonho But it’s on the roadmap? How would that work? Would the interop tool generate the JNI interface for you? Because I’m assuming you would need the JNI interface for the JVM
a
I see, but does it work like I described? I’m curious how it works under the hood
o
under the hood it generates Kotlin/JVM bridges and matching JNI stubs
a
That’s fantastic, so awesome! Can I try it out already? Do I simply use it like any other C library but in the multiplatform project rather than the native project?
o
It doesn’t work like that out if the box
But you may try to hack it
a
I see, thanks!
d
Exciting!