Hey there, I'm researching Kotlin Native and I'm w...
# kotlin-native
m
Hey there, I'm researching Kotlin Native and I'm wondering if it's possible to build a library instead of an executable. And if so, how do you then make that library callable from another language (for example C)
o
maku: currently, we do not support this mode of execution of Kotlin/Native as it requires significant design time for embedding API, however, one could rather easily emulate what you asked for by calling C function using interop like is being done in https://github.com/JetBrains/kotlin-native/tree/master/samples/concurrent/
m
Yeah, I saw that, but my use case is as follows: we have existing C code that's our main service. We also have a Kotlin package/module/library that provides some functionality, at the moment we transpile kotlin code to JS and run it from C process using JS VM. I'd like to get rid of the JS VM and just call the kotlin methods directly.
o
That shalln't be hard, just init Kotlin runtime, declare called functions with @ExportForCppRuntime annotations and call your API. See https://github.com/JetBrains/kotlin-native/blob/master/runtime/src/launcher/cpp/launcher.cpp