Hi, is it possible to use c/c++ code in kotlin-nat...
# kotlin-native
f
Hi, is it possible to use c/c++ code in kotlin-native (similarly to JNI?). I'm going to write program that executes inside Raspberry Pi and i might need some native code to communicate with external devices 🙂
a
Yes, you can generate bindings for native libraries and utilize them in your code. See doc for clarification, or have a look at the gitchurn sample from the K/N repository. It shows an example of
libgit2
library use.
m
so, is it possible to generate kotlin bindings for a C++ library with cinterop? instead of use JNI to communicate with the native side...
f
Thanks Artyom i will take a look
a
No, @magnumrocha, C++ interop is not available. If you can somehow wrap your library to look as a C one - maybe it will be possible.
👍 1
m
thanks @Artyom Degtyarev [JB]
n
@felislynx - Presumably you are doing some form of embedded development. If that is the case then try to use C libraries if possible since most embedded development libraries are written in C. Few embedded development libraries are written in C++ (most of those are Arduino related).
Bartosz - What kind of sw development are you trying to do?
f
@napperley Kind of alerting system for vehicles. You are right, most of libs are in C for my external devices but some are in c++ or python. This will be nice hybrid system in Raspberry Pi 😄
Normally i would do it in Python but General decision was to use Kotlin
m
I've worked in a company where there is a big Map Rendering Engine implemented in C++ with apps for Android (Kotlin) and iOS (Swift), in the time I was there, I've study kotlin native to realize if we could change from C++ to a high level language and left JNI code in Android (many headaches...), but the interop with the C++ was essential (the devs won't rewrite the engine part from scratch)