Roberto Leinardi
11/04/2024, 8:14 PMlinkDebugExecutableLinuxX64
task.
I have a dedicated module for the WebKit bindings with a cinterop
def file (webkit.def), which builds fine. However, when I try using it as a dependency in a sample app module, I get these errors:
e: /home/leinardi/.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
[...]
/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so: error: undefined reference to 'dlclose', version 'GLIBC_2.34'
/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so: error: undefined reference to 'dlsym', version 'GLIBC_2.34'
/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so: error: undefined reference to 'dlopen', version 'GLIBC_2.34'
/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so: error: undefined reference to 'dlerror', version 'GLIBC_2.34'
Based on what I found online, adding -Wl,--no-as-needed -ldl
to linkerOpts
should help, but that gives an error: ld.gold: -Wl,--no-as-needed: unknown option
.
For context:
• I'm new to cinterop
and am primarily an Android dev.
• The WebKit binding module depends on two other cinterop
modules (atk.def and soup.def), so the issue might be in one of these modules.
Interestingly, if I use the GTK4 bindings (gtk4.def) without the WebKit dependency, the sample project runs without issues so I assume it must be something int he webkit.def
file.
Any advice on resolving the linking errors? Thanks in advance! 🙏loke
11/10/2024, 10:22 AM.def
file:
linkerOpts.linux = <lib names here> --allow-shlib-undefined
Roberto Leinardi
11/13/2024, 8:59 AM--allow-shlib-undefined
actually made it build, link and run! Since I'm creating bindings for GObject libraries, do you think that using this linker option could cause some issue? Or make debugging runtime errors more difficult?Roberto Leinardi
11/13/2024, 11:43 AMkotlin.incremental.native=true
cuts the build and link time from minutes to seconds once the klib artifacts are cachedloke
11/14/2024, 7:50 AMloke
11/14/2024, 7:51 AMloke
11/14/2024, 7:54 AMloke
11/14/2024, 7:57 AMRoberto Leinardi
11/14/2024, 8:17 AM--allow-shlib-undefined
and just deal with eventual runtime errors. Thanks again!Roberto Leinardi
11/14/2024, 8:17 AMloke
11/14/2024, 8:32 AMloke
11/14/2024, 8:35 AM.def
file, in the explicit C section) and then use it. That would cause a link error without the flag but a runtime error with it. I have never done this.loke
11/14/2024, 9:19 AMloke
11/14/2024, 9:19 AMRoberto Leinardi
11/14/2024, 9:31 AMtargetSysRoot
, so that it will use the host glibc instead of the bundled one. I found this blog post and still playing with it: https://zachary.grafton.me/2024/01/21/kotlin-native-on-fedora-39.htmlloke
11/14/2024, 9:34 AMRoberto Leinardi
11/14/2024, 9:42 AMRoberto Leinardi
11/14/2024, 10:25 AMbinaries {
executable {
entryPoint = "org.gtkkn.samples.gtksource.sample.main"
freeCompilerArgs += listOf(
"-Xoverride-konan-properties=targetSysRoot.linux_x64=/" //Change buildroot location
+ ";libGcc.linux_x64=/usr/lib/gcc/x86_64-linux-gnu/13" //Look for libGcc in the correct place
+ ";linker.linux_x64=/usr/bin/ld.bfd" //Use a proper linker, gold seems to choke on some newer stuff
+ ";crtFilesLocation.linux_x64=/usr/lib/x86_64-linux-gnu/", //Tell Kotlin where to find some C runtime libraries
)
}
}
loke
11/14/2024, 10:57 AMloke
11/14/2024, 10:57 AMloke
11/14/2024, 10:58 AMloke
11/14/2024, 10:58 AMRoberto Leinardi
11/14/2024, 10:59 AMloke
11/14/2024, 11:00 AM