android compilation fails sqlite
Describe the bug
Hey, I continue on my tauri android dev journey. I think I found a bug regarding sqlite3. As soon to my tauri project I add sqlx with sqlite feature enabled as dependency, the project fails to compile with the following error (shortened) :
Compiling ...
error: linking with `/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang` failed: exit status: 1
|app:rustBuildX86_64Debug
= note: "/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang" [...]
= note: ld: error: undefined symbol: __extenddftf2
>>> referenced by sqlite3.c:29950 (sqlite3/sqlite3.c:29950)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/
error: could not compile `nym_connect` due to previous error
Error `Failed to run `cargo build`: Command "cargo build --package nym_connect --manifest-path /home/pierre/Documents/nym/nym/nym-connect/src-tauri/Cargo.toml --target x86_64-linux-android --no-default-f
eatures --color always" didn't complete successfully, exiting with code 101.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:rustBuildX86_64Debug'.
> Process 'command '/home/pierre/.cargo/bin/cargo-tauri'' finished with non-zero exit value 1
Reproduction
No response
Expected behavior
No response
Platform and versions
Environment › OS: Arch Linux Unknown X64 › Node.js: 16.17.1 › npm: 8.15.0 › pnpm: Not installed! › yarn: 1.22.19 › rustup: 1.25.1 › rustc: 1.66.1 › cargo: 1.66.1 › Rust toolchain: stable-x86_64-unknown-linux-gnu
Packages WARNING: no lock files found, defaulting to npm › @tauri-apps/cli [NPM]: 2.0.0-alpha.1 › @tauri-apps/api [NPM]: 2.0.0-alpha.0 › tauri [RUST]: 2.0.0-alpha.2, › tauri-build [RUST]: 2.0.0-alpha.0, › tao [RUST]: 0.15.8, i › wry [RUST]: 0.23.4,
App › build-type: bundle › CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self' › distDir: ../dist › devPath: http://localhost:9000/ › framework: React › bundler: Webpack
App directory structure ├─ public ├─ src-tauri ├─ node_modules ├─ src └─ dist
Stack trace
Compiling ...
error: linking with `/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang` failed: exit status: 1
|app:rustBuildX86_64Debug
= note: "/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang" "-m64" "/tmp/rustcxs0jcl/symbols.o" [...] "-Wl,--gc-sections" "-pie"
"-Wl,-zrelro,-znow" "-nodefaultlibs" "-landroid" "-llog" "-lOpenSLES"
= note: ld: error: undefined symbol: __extenddftf2
>>> referenced by sqlite3.c:29950 (sqlite3/sqlite3.c:29950)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29952 (sqlite3/sqlite3.c:29952)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29980 (sqlite3/sqlite3.c:29980)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced 4 more times
ld: error: undefined symbol: __lttf2
>>> referenced by sqlite3.c:29963 (sqlite3/sqlite3.c:29963)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29996 (sqlite3/sqlite3.c:29996)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29997 (sqlite3/sqlite3.c:29997)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced 1 more times
ld: error: undefined symbol: __trunctfdf2
>>> referenced by sqlite3.c:29975 (sqlite3/sqlite3.c:29975)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29980 (sqlite3/sqlite3.c:29980)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29985 (sqlite3/sqlite3.c:29985)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced 4 more times
ld: error: undefined symbol: __multf3
>>> referenced by sqlite3.c:29980 (sqlite3/sqlite3.c:29980)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29992 (sqlite3/sqlite3.c:29992)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29992 (sqlite3/sqlite3.c:29992)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced 12 more times
ld: error: undefined symbol: __addtf3
>>> referenced by sqlite3.c:29980 (sqlite3/sqlite3.c:29980)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29981 (sqlite3/sqlite3.c:29981)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:30012 (sqlite3/sqlite3.c:30012)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
ld: error: undefined symbol: __gttf2
>>> referenced by sqlite3.c:29990 (sqlite3/sqlite3.c:29990)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:84101 (sqlite3/sqlite3.c:84101)
>>> sqlite3.o:(sqlite3IntFloatCompare) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
ld: error: undefined symbol: __getf2
>>> referenced by sqlite3.c:29992 (sqlite3/sqlite3.c:29992)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29993 (sqlite3/sqlite3.c:29993)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:29994 (sqlite3/sqlite3.c:29994)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced 1 more times
ld: error: undefined symbol: __divtf3
>>> referenced by sqlite3.c:29995 (sqlite3/sqlite3.c:29995)
>>> sqlite3.o:(sqlite3_str_vappendf) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:33174 (sqlite3/sqlite3.c:33174)
>>> sqlite3.o:(sqlite3AtoF) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:33194 (sqlite3/sqlite3.c:33194)
>>> sqlite3.o:(sqlite3AtoF) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
ld: error: undefined symbol: __fixtfsi
>>> referenced by sqlite3.c:29563 (sqlite3/sqlite3.c:29563)
>>> sqlite3.o:(et_getdigit) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
ld: error: undefined symbol: __floatsitf
>>> referenced by sqlite3.c:29564 (sqlite3/sqlite3.c:29564)
>>> sqlite3.o:(et_getdigit) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
ld: error: undefined symbol: __subtf3
>>> referenced by sqlite3.c:29566 (sqlite3/sqlite3.c:29566)
>>> sqlite3.o:(et_getdigit) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
ld: error: undefined symbol: __floatditf
>>> referenced by sqlite3.c:33174 (sqlite3/sqlite3.c:33174)
>>> sqlite3.o:(sqlite3AtoF) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:33177 (sqlite3/sqlite3.c:33177)
>>> sqlite3.o:(sqlite3AtoF) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced by sqlite3.c:33194 (sqlite3/sqlite3.c:33194)
>>> sqlite3.o:(sqlite3AtoF) in archive /home/pierre/Documents/nym/nym/nym-connect/src-tauri/target/x86_64-linux-android/debug/deps/liblibsqlite3_sys-5f379e2f837b94c7.rlib
>>> referenced 2 more times
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
error: could not compile `nym_connect` due to previous error
Error `Failed to run `cargo build`: Command "cargo build --package nym_connect --manifest-path /home/pierre/Documents/nym/nym/nym-connect/src-tauri/Cargo.toml --target x86_64-linux-android --no-default-f
eatures --color always" didn't complete successfully, exiting with code 101.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:rustBuildX86_64Debug'.
> Process 'command '/home/pierre/.cargo/bin/cargo-tauri'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Error Failed to assemble APK: Command "/home/pierre/Documents/nym/nym/nym-connect/src-tauri/gen/android/nym_connect/gradlew --project-dir /home/pierre/Documents/nym/nym/nym-connect/src-tauri/gen/android/
nym_connect assembleX86_64Debug --warn" didn't complete successfully, exiting with code 1.
Additional context
No response
https://github.com/termux/termux-packages/issues/14576 or https://github.com/termux/termux-packages/issues/8029 seem to be the same/a similar problem.
The solution/workaround seems to be to add additional link arguments in src-tauri/.cargo/config.toml. But everything i do in this file is immediately overriden once i run npm run tauri android dev.
Another solution I tried was to downgrade to ndk version 22 but then i get ld: error: unable to find library -lunwind.
got same error, i dont know how to fix it
有同样的错误,也还没有找到解决方案
找到了一个临时解决方案有效解决了编译sqlite3 ld: error: undefined symbol: __extenddftf2 的问题
借用这里的思路:https://github.com/termux/termux-packages/issues/8029
在.cargo/config.toml 中针对异常的编译目标(x86_64-linux-android)添加 rustflags 参数,我的参数如下:
[target.x86_64-linux-android]
linker = '$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang'
rustflags = [
'-L',
'/home/one/code/chat-gpt-gui-dev/server/.cargo',
'-Clink-arg=-landroid',
'-Clink-arg=-llog',
'-Clink-arg=-lOpenSLES',
'-Clink-arg=-lOpenSLES',
'-Clink-arg=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.6/lib/linux/libclang_rt.builtins-x86_64-android.a',
]