How can I publish a native dependency as klib with...
# kotlin-native
j
How can I publish a native dependency as klib with the static library (a) included? For context the current build script: https://github.com/marykdb/rocksdb/blob/feature/native-implementation/build.gradle.kts The current published results: https://bintray.com/maryk/maven/RocksDB/0.3.0#files/io/maryk/rocksdb
m
Hm, static library is
.a
,
.so
is shared library. If you really want static - https://github.com/msink/kotlin-libui/blob/40349d6f6e2a32b12064eb4385907aa476626bb3/libui/build.gradle.kts#L59
p
See https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md if your cinterop defines
staticLibraries
and
libraryPaths
the found static library in the given path will be bundled into your klib.
j
@msink Ah stupid I have indeed .a files. Searching the documentation somewhere corrupted my memory.
@Paul Idstein Thanks! I seem to have somehow missed that clear part of the documentation.
m
Sure, but
libraryPaths
cannot be used if your path is relative - https://github.com/JetBrains/kotlin-native/issues/2314
p
@msink yes that‘s true. We faced the same issue until we found a workaround passing the libraryPaths via gradle and don‘t define them from the def file itself. Tomorrow I can post you the gradle magic to inject an absolut path using $buildDir string substitution.
m
Isn't it the same as in my first answer?
p
It is a little bit different as it is contained to the scope of cinterops (adding via extraOpts). Your command will add at all cost add a binary to the final klib. We found it more suitable to keep
staticLibraries
inside def file and only inject the lookup path via gradle. Ultimately, you‘re right you‘re solution does exactly what the describe documentation states is happening.
j
Ah it works for me now with a relative dir but I see it is because I don't have a multiproject build and always build from the root directory. Good to know the current behavior!