Hi all once more, my apologies for the abudance of...
# kotlin-native
t
Hi all once more, my apologies for the abudance of questions, I am quite new to this technology, and as a project I am hoping to port a few simple things I made in C into Kotlin/Native. The biggest problem is that it is not easy to compile Kotlin Native on a raspberry pi, it took me a really long time to compile a simple hello world application! I do though, want to access the WiringPi library, which allows you to work with the GPIO pins on raspberry pi's. The library is already installed on Raspberry Pi's, and unfortunately the creator does not distribute static files, and only the .so files which can be only installed on a raspberry pi, from what i've been able to research. My question is, if I want to use the library's functionality within a Kotlin Native project, I know that I would have to use it as a dynamic library, but how would I go about linking it to my project? Would that be possible, or would I have to stick to waiting for a long time while it compiles on the raspberry pi. I also thought of the idea of copying the .so files from the raspberry pi into my workspace on my mac computer, and linking it through that way. I'm not sure whether this would work or not, and I would like to know what is the best course of action I should take, or just stick to C and not attempt this
k
are the libraries written in C or C++?
t
C
k
then you can create bindings for the library using cinterop
t
hmm, i think i know what to do now. i'll see if i got this right
n
@Timothy Wong - Currently there is discussion around having a repository that contains klibs (C lib wrappers), which cover some of the common C libs. This would eliminate many of the tedious steps with linking C libraries to a Kotlin Native program/lib. Kotlin Native libraries (klibs - https://kotlinlang.org/docs/reference/native/libraries.html ) are much easier to deal with than C ones.
In the Kotlin Native repository is a libcurl sample ( https://github.com/JetBrains/kotlin-native/tree/master/samples/libcurl ) that shows how to create a Kotlin Native lib that wraps a C lib.
t
Thanks for the information about porting common libraries over. That does seek like a smart thing to do!