I'm considering using Kotlin native to make an exe...
# kotlin-native
s
I'm considering using Kotlin native to make an executable that wraps a C library and allows interfacing with it. Is there any reason that I should be wary of using Kotlin Native for this? I need to make executables that run on Mac and windows On x86 and arm.
c
What would you be interfacing via?
s
What do you mean?
c
You want to interface with a C library through Kotlin, so what will use the interface?
s
oh - I thought Kotlin can call into C functions. I believe I can use the header files to generate the Kotlin stubs or something. I’m very new to native programming
If there is something better, I’m open to that as well
u
Kotlin native is not an alternative to JNI. Kotlin JVM can not call directly into C and neither into kotlin native
👍 1
s
@uli I’m aware. I’ve recently had problems using JNI from the JVM, and so I’m trying a new strategy where I create a Kotlin Native application / executable that interacts with the native library directly, and that I can call as a separate process.
u
His do you intend to communicate with the KN executable?
s
I expect responses in stdout. Every time I have a “request”, I’d just create a separate process.
Does that make sense?
u
If you are fine with the heavyness of forking a new process every time, this sounds like a reasonable approach
s
yes - the requests won’t happen often enough, that this will be a problem.
I’m having problems getting C interop to find all the library headers, and link the dylib on mac - if you have any insight to that on my other questions below 🙂
s
Did you ever find an answer to this @spierce7?
s
Yes
I was able to get it working
s
Do you have any public example?