Calling C/C++ from Kotlin Multiplatform library (klib)

I am currently developing an Android app written in Kotlin and C++, which used JNI to bind C++ to Java and thereby Kotlin. The C++ part is written using JUCE, a cross-platform library. In order to avoid code duplication on iOS, and simplify future development, I am looking into Kotlin Multiplatform to separate the “business logic” parts of the app into a klib.

It looks like Kotlin Native is fully capable of interop with C and thereby C++ (with extern C blocks). What I am not clear on, is if I can call into C code from the klib. What I would like is to bypass JNI and be able to call into C++ code directly from Kotlin, as well as provide callbacks for the C++ code to call Kotlin methods.

Is this possible? Are there any examples of Multiplatform libraries that do this?

Hi there
I’m not sure about calling kotlin functions from C code, as the kotlin backend mangle names and manage its memory itself, but there is a part on the documentation about passing callbacks.