Hello guys, I am trying to use a C-library in my K...
# kotlin-native
k
Hello guys, I am trying to use a C-library in my Kotlin based app. I have gone through the official documentation, but I didn't find a resource that explains how to add a C-library as dependency to an Android Project and can be used in the SharedCode Kotlin module! Any help appreciated.
s
Hello. As we have discussed earlier https://kotlinlang.slack.com/archives/C3PQML5NU/p1559830111022800 you can’t add C library to Android project using Kotlin/JVM.
k
is there any way to add a C-library at all without using Kotlin/JVM and still use it in an Android app?
s
No, Kotlin/JVM is Kotlin backend used for Android apps.
k
oh, okay. Thank you. Suppose I have a library like this https://libzip.org
How do I use it?
And what about C++ library?
f
Search for a Java zip library
👍 1
s
The only option currently available for native library on Android is to wrap it manually with JNI. Some extra wrapping would be required to use this library in common code (which is compiled to both Android and iOS).
k
Thank you @svyatoslav.scherbina
k
@Kruger Brent check out Djinni
k
Cool. Yeah just stumbled over that. Thanks though @Kris Wong
@Kris Wong does it translate the C code to C++?
k
no
it generates the bindings
k
How do I link a CPP module in a kotlin/native project? I mean there aren't any samples explaining that anywhere on the kotlin website. A sample gradle file to include a CPP module or something like that!
s
Importing C++ libraries is not supported.
👍 1