Hey all, got this error when linking a C library t...
# kotlin-native
a
Hey all, got this error when linking a C library to a Kotlin Native app:
Copy code
> Task :linkDebugExecutableNativeLinuxX64

e: /home/runner/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold invocation reported errors
The /home/runner/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold command returned non-zero exit code: 1.
output:
/usr/lib/x86_64-linux-gnu/libtinfo.so: error: undefined reference to 'stat', version 'GLIBC_2.33'
/usr/lib/x86_64-linux-gnu/libncurses.so.6: error: undefined reference to 'dlopen', version 'GLIBC_2.34'
/usr/lib/x86_64-linux-gnu/libncurses.so.6: error: undefined reference to 'dlclose', version 'GLIBC_2.34'
/usr/lib/x86_64-linux-gnu/libncurses.so.6: error: undefined reference to 'dlsym', version 'GLIBC_2.34'

> Task :linkDebugExecutableNativeLinuxX64 FAILED
Apparently, glibc bundled with Kotlin Native toolchain (2.19 in
x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2
) is of lower version than might be required (
GLIBC_2.33
). Any clues on how to resolve that would be welcome. Thanks!
a
Hi, are you compiling the C lib from source? If so you can use run_konan util to run K/N's gcc https://github.com/JetBrains/kotlin/blob/v1.9.22/kotlin-native/HACKING.md#running-clang-the-same-way-kotlinnative-compiler-does Easier said than done! I've got a couple of Gradle util tasks that can compile C into K/N-compatible libs. They're a bit messy, but I'll chuck them into a gist.
a
Hey Adam, thanks for an interesting idea and the gist, I also figure before invoking your code there is a need to tell Konan to replace the dependency it’s using (
x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2
) with one that has glibc 2.34, not sure how this can be done. I’ve also filed an issue for the Kotlin team, for reference.
a
Well... No exactly a solution... I would say a workaround... You can use docker for setting your build environment. See this thread.
I hope this helps you somehow...
a
I assume this might have solved your issue because container installs
curl
version which is happy with current CLang toolchain which Konan uses nowadays. Probably I can also play with versions of NCurses needed for my case. Thanks for clues!