Mismatch between glibc versions (Kotlin/Native on Linux)

Consider the following example:

  1. Project foo is a KMP library with cinterop dependencies. The dependencies are built with system toolchain and target system libraries, e.g. glibc > 2.20
  2. Project bar is a KMP / KN executable with a dependency on foo. When konan is invoked to build and link bar, it uses its own bundled LLVM and sysroot
  3. The sysroot bundled with konan (available in ~/.konan/dependencies) is heavily outdated (kernel 4.9.2, glibc 2.19) even though the LLVM toolchain is relatively recent (LLVM-19 essentials as of October 2025).

When I build this project targeting any other platform (iOS, macOS, Android – although it uses nativeExternalBuild instead of cinterop) the resulting binary links and runs fine. But when building for Linux it fails with linker errors and missing symbols from glibc.

Providing accurate real paths with linkerOpts does not appear to change anything (likely since the “sysroot” variants take precedence). After a longer investigation I managed to link with the following configuration:

linkerOpts.addAll(listOf(
    "-L/usr/lib/x86_64-linux-gnu",
    "-lc++",
    "--allow-shlib-undefined",
    "--unresolved-symbols=ignore-all",
    "--warn-unresolved-symbols",
))

and forcing libc++ in both projects.

This is not a new issue, c.f.:


In general, what is the recommended way to tackle these kinds of problems? I feel like it took me way too long to solve (or rather sweep under the rug) something that should be relative simple and work out of the box. In the coming days I might try to build the cinterop package with the bundled toolchain (see the last link), but to be frank, glibc 2.19 has been released over 11 years ago and it lacks some pretty important security features.

1 Like