Newbie here… I’m taking another stab at learning K...
# kotlin-native
c
Newbie here… I’m taking another stab at learning Kotlin native and I need help understanding how bindings work. When you run the cinterop tool it generates a .klib from the headers defined in the given .def file. Does the klib link to the native library dynamically or statically? I don’t understand when/how the native library is resolved. Does it need to be in a special LD_LIBRARY path when running the final binary produced by kotlinc? Or does it somehow get compiled into the binary when running the kotlinc cmd?
o
"Does the klib link to the native library dynamically or statically?" -> it could be either one, depending on linkerOpts, if you provide dynamic libs like
-lfoo
it will link dynamically, if you'll have
libfoo.a
- it will be linked statically into the final binary. But native libraries are not included in klib, so they have to be present on machine where klib is used.
"Does it need to be in a special LD_LIBRARY path when running the final binary produced by kotlinc" -> it depends on platform, and is no different from other native binaries (i.e. if it is in /usr/lib or listed in /etc/ld.resolve.conf on Linux) - no need to do anything, otheriwse LD_LIBRARY_PATH or DYLD_LIBRARY_PATH or similar is needed