katokay
03/26/2025, 2:52 PMAdam S
03/26/2025, 6:55 PMkatokay
03/26/2025, 7:42 PMMatt Nelson
03/27/2025, 1:11 PM.so
, .dylib
, .dll
files via a .klib
publication unless you do something like base64 encode the precompiled native libs into a .kt
file, compile that, and then have some sort of framework to extract that to a temp location at runtime and use `dlopen`/`dlsym`. from kotlin/Native
(e.g. kmp-tor-common:NativeResource)
Additionally, you would need to codesign macos
and mingw
libs if you're loading things dynamically, otherwise library consumers would need to codesign them.
The simplest way is to have the kotlin compiler build the native code and embed it in the .klib
bitcode. Checkout cklib for that.katokay
03/27/2025, 1:26 PMMatt Nelson
03/27/2025, 1:53 PM.klib
. There are so many falling knives (e.g. glibc versions). I only do that with kmp-tor
because the tor
C library is, well, very complicated.
If you're writing C code instead of Kotlin/Native
, either do so in the .def
file like:
package = my.package.internal
---
#include <errno.h>
static int
something()
{
return 2;
}
or use cklib
to compile the thing using the kotlin compiler.katokay
03/27/2025, 2:54 PM