https://kotlinlang.org logo
Title
k

Kolby Kunz

04/26/2023, 8:03 PM
With kotlin native how do I include a created cinterop library with the final executable. Currently when I try to run the executable generated from my project it is looking for the .so file the corresponds to the library that I used the cinterop tool on, I would rather that this gets built into the final executable so that the end user does not have to install this dependency along with the project. I have already tried to use the staticLibrary option in the .def file
l

Landry Norris

04/26/2023, 10:16 PM
You'll need a static library to do that (.a instead of .so). Shared objects have to be on the linker path at runtime. Static libraries get built into the executable.
k

Kolby Kunz

04/26/2023, 10:17 PM
Okay I see. I am assuming that is a limitation of using the underlying compiler.
Thank you
l

Landry Norris

04/26/2023, 10:18 PM
That's just how ELF works. If you want it to be statically linked, you need libfoo.a
k

Kolby Kunz

04/26/2023, 10:18 PM
Sweet. I will recompile for that then
p

Pavel Gorgulov

04/27/2023, 5:26 PM
note that cinterop and commonize don't work on kotlin 1.8.20. use 1.8.21 or earlier. also, if you have any questions, you can look at how I statically link the library - https://github.com/Kotlin/multik/blob/develop/multik-openblas/cinterop/libmultik.def https://github.com/Kotlin/multik/blob/develop/multik-openblas/build.gradle.kts#L70