:compose: :desktop_computer: Does anyone has exper...
# compose-desktop
b
✏️ 🖥️ Does anyone has experience with Compose for Desktop and using a native c library? I was able to load the native library desktop
Copy code
val resources = File(System.getProperty("compose.application.resources.dir")).parent
System.load(File(resources, "libutil.dylib").absolutePath)
But I don’t know how I can access it.
@Emmanuel loading the
.dylib
isn’t an issue. But I don’t know, how to access it via an JNI or c-interop call from inside kotlin.
r
Same as you would in Java, via JNI. In fact, you can write your JNI code in Java and just call it from Kotlin. See https://kotlinlang.org/docs/java-interop.html#using-jni-with-kotlin
l
You can also write K/N code that calls into the library and a Kotlin object to call into your K/N like in https://github.com/LandryNorris/JniUtils sample module.
b
ah sure, I had to add
JNIEXPORT
and
JNICALL
to the library to get access from outside.🎉