I have created multiplatform library with some cin...
# kotlin-native
f
I have created multiplatform library with some cinterop libraries for
linuxArm64
and
linuxX64
. I published the library to my local maven repo. Now when i try to use the library in some project on
linuxX64
the build goes fine, but when i try to compile for
linuxArm64
i get
cannot find -l<library name>
and bunch of
undefined reference to <something>
. The library has
def
file with different linker paths for each architecture and build of the library goes fine for all build targets. The problem is only when i try to use the published library. So i am wondering what might be wrong here ?
So i found out that the
.so
files must be on the same path as defined in the
.def
in the library even in the project that uses the library. Is there a way to package the library with the
.so
files it uses? I want to just add the library in the gradle and for it to work. So i dont have to worry about having all the
.so
files in the correct path
n
Best practice for setting linking options is to do it on the Kotlin Native program side. A Kotlin Native library shouldn't be specifying linking options in order to be portable across platforms. Linking options can vary between Linux distributions.
Alternatively static library files can be packaged with a Kotlin Native library, which has the big advantage of having all linking managed on the library side, instead of dealing with it on the program side.
f
@napperley what do i have to do to package the static library files with the kotlin native library ?
n
Specify the linking information in the def file, and put all static libraries in a directory that is inside the project (eg c_libs). Below is an example def file (based on this Kotlin Issue - https://youtrack.jetbrains.com/issue/KT-24649/Kotlin-Native-an-option-to-include-static-dynamic-library-into-klib#focus=Comments-27-2909933.0-0):
Copy code
staticLibraries = libui.a
libraryPaths = c_libs
188 Views