kotbase icon indicating copy to clipboard operation
kotbase copied to clipboard

I seem to getting a link error at the lowest level

Open bpappin opened this issue 1 year ago • 5 comments

Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/

This happens when i have the core lib and the ktx lib included as a dependency in commonMain (KMP).

I seem to be able to reproduce it simply by including the libraries in my dependency list.

bpappin avatar Apr 13 '25 04:04 bpappin

Native platform targets do need to link directly to the Couchbase Lite native binary in addition to the Kotbase dependency in Kotlin, as described in the docs.

For the iOS target, the simplest way to link to the iOS CouchbaseLite.framework is with the Kotlin/Native CocoaPods plugin. See example.

Alternatively, you can also manually link to the binary as well. See example, which includes iOS, macOS, Linux, and Mingw native targets.

Which platform targets are you using? Which target is experiencing the linker error? If necessary, please share your build configuration.

(Unrelated, but the ktx lib has an API dependency on the core lib, so you don't need to depend on both explicitly.)

jeffdgr8 avatar Apr 16 '25 07:04 jeffdgr8

I was receiving the link error in the Android target. I did manage to figure out that I needed both libraries. The build config is essentially the config from the KMP project wizard, so its not all that unusual.

For iOS we are using all SPM dependencies and we have been avoiding cocopods dependencies.

I am reading the supported platforms, but am not finding it all that clear what else needs to be be done, besides including those two dependencies. Once android is working, I would them attempt to get the iOS side working.

bpappin avatar Apr 16 '25 22:04 bpappin

This is unexpected for the Android target, which shouldn't need any manual linking of native binaries. This could be a bug in the underlying Couchbase Lite library. Could you share a complete stack trace from the crash? Are you able to share a reproducer sample project?

jeffdgr8 avatar Apr 16 '25 22:04 jeffdgr8

I had to rip it out again to keep working. When i'm finished this story, I can try and put it back in and see if I get the same error. I'd like to use it if I can. I'll have to get back to you though.

bpappin avatar Apr 17 '25 21:04 bpappin

Ok. Please share additional info when you are able.

I'd also be interested to see if adding the Couchbase Lite library (com.couchbase.lite:couchbase-lite-android:3.1.9) by itself to the Android target results in the same issue. Kotbase mostly typealiases or at most provides a lightweight wrapper around the Couchbase Lite Java and Android SDKs for those targets. All linking and interfacing with the native Couchbase Lite core binary is done within the Couchbase Lite SDK. The other native platform targets are the ones that add the complexity of cinterop and interfacing between Kotlin and the native platform libraries.

jeffdgr8 avatar Apr 17 '25 23:04 jeffdgr8

Please let me know if you are still experiencing issues. Closing this for now.

jeffdgr8 avatar Oct 25 '25 08:10 jeffdgr8