Cross Compiling for Android

Hi, i'm trying to cross compile a library lib for android. When a build the project without the mmkv crate it compiles without any problem, but as soon as i include it back on the project i start receivng the error bellow.

Any help is much appreciated.

Execution failed for task ':react-native-mmkv-rs:buildCMakeDebug[x86]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86'
  [0/5] cd /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv && /home/daniel/Android/Sdk/cmake/3.22.1/bin/cmake -E env CARGO_TARGET_I686_LINUX_ANDROID_LINKER=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CC_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CXX_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ CORROSION_BUILD_DIR=/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86 CARGO_BUILD_RUSTC=/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc /home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo rustc --lib --target=i686-linux-android --package rust-mmkv --manifest-path /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv/Cargo.toml --target-dir /home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build -- -Clink-args=--sysroot=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Cdefault-linker-libraries=yes -Clink-args=--target=i686-none-linux-android21
  FAILED: CMakeFiles/_cargo-build_rust-mmkv /home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/CMakeFiles/_cargo-build_rust-mmkv 
  cd /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv && /home/daniel/Android/Sdk/cmake/3.22.1/bin/cmake -E env CARGO_TARGET_I686_LINUX_ANDROID_LINKER=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CC_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CXX_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ CORROSION_BUILD_DIR=/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86 CARGO_BUILD_RUSTC=/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc /home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo rustc --lib --target=i686-linux-android --package rust-mmkv --manifest-path /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv/Cargo.toml --target-dir /home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build -- -Clink-args=--sysroot=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Cdefault-linker-libraries=yes -Clink-args=--target=i686-none-linux-android21
  ninja: build stopped: subcommand failed.

* Try:
> 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.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-native-mmkv-rs:buildCMakeDebug[x86]'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:147)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:135)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:331)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:318)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.lambda$execute$0(DefaultTaskExecutionGraph.java:314)
	at org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:80)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:314)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
Caused by: org.gradle.internal.UncheckedException: com.android.ide.common.process.ProcessException: ninja: Entering directory `/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86'
[0/5] cd /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv && /home/daniel/Android/Sdk/cmake/3.22.1/bin/cmake -E env CARGO_TARGET_I686_LINUX_ANDROID_LINKER=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CC_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CXX_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ CORROSION_BUILD_DIR=/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86 CARGO_BUILD_RUSTC=/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc /home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo rustc --lib --target=i686-linux-android --package rust-mmkv --manifest-path /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv/Cargo.toml --target-dir /home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build -- -Clink-args=--sysroot=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Cdefault-linker-libraries=yes -Clink-args=--target=i686-none-linux-android21
FAILED: CMakeFiles/_cargo-build_rust-mmkv /home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/CMakeFiles/_cargo-build_rust-mmkv 
cd /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv && /home/daniel/Android/Sdk/cmake/3.22.1/bin/cmake -E env CARGO_TARGET_I686_LINUX_ANDROID_LINKER=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CC_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang CXX_i686_linux_android=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ CORROSION_BUILD_DIR=/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86 CARGO_BUILD_RUSTC=/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc /home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo rustc --lib --target=i686-linux-android --package rust-mmkv --manifest-path /home/daniel/Documentos/mobile/react-native-mmkv-rs/rust-mmkv/Cargo.toml --target-dir /home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build -- -Clink-args=--sysroot=/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Cdefault-linker-libraries=yes -Clink-args=--target=i686-none-linux-android21
ninja: build stopped: subcommand failed.

C++ build system [build] failed while executing:
    /home/daniel/Android/Sdk/cmake/3.22.1/bin/ninja \
      -C \
      /home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86 \
      react-native-mmkv-rs
  from /home/daniel/Documentos/mobile/react-native-mmkv-rs/android
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.153
   Compiling typenum v1.17.0
   Compiling version_check v0.9.4
   Compiling thiserror v1.0.56
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling protobuf v3.3.0
   Compiling rustix v0.38.31
   Compiling linux-raw-sys v0.4.13
   Compiling generic-array v0.14.7
   Compiling bitflags v2.4.2
   Compiling indexmap v1.9.3
   Compiling memchr v2.7.1
   Compiling anyhow v1.0.79
   Compiling quote v1.0.35
   Compiling fastrand v2.0.1
   Compiling syn v2.0.48
   Compiling getrandom v0.2.12
   Compiling home v0.5.9
   Compiling rand_core v0.6.4
   Compiling aho-corasick v1.1.2
   Compiling regex-syntax v0.8.2
   Compiling either v1.9.0
   Compiling once_cell v1.19.0
   Compiling hashbrown v0.12.3
   Compiling log v0.4.20
   Compiling crypto-common v0.1.6
   Compiling inout v0.1.3
   Compiling block-buffer v0.10.4
   Compiling cipher v0.4.4
   Compiling num-traits v0.2.18
   Compiling subtle v2.5.0
   Compiling protoc-bin-vendored-linux-ppcle_64 v3.0.0
   Compiling protoc-bin-vendored-macos-x86_64 v3.0.0
   Compiling protoc-bin-vendored-win32 v3.0.0
   Compiling protoc-bin-vendored-linux-aarch_64 v3.0.0
   Compiling protoc-bin-vendored-linux-x86_64 v3.0.0
   Compiling protoc-bin-vendored-linux-x86_32 v3.0.0
   Compiling digest v0.10.7
   Compiling which v4.4.2
   Compiling tempfile v3.10.0
   Compiling protoc-bin-vendored v3.0.0
   Compiling dbl v0.3.2
   Compiling android_system_properties v0.1.5
   Compiling glob v0.3.1
   Compiling lazy_static v1.4.0
   Compiling bytes v1.5.0
   Compiling java-locator v0.1.5
   Compiling regex-automata v0.4.5
   Compiling combine v4.6.6
   Compiling iana-time-zone v0.1.60
   Compiling cmac v0.7.2
   Compiling ctr v0.9.2
   Compiling aead v0.5.2
   Compiling libloading v0.7.4
   Compiling crc-catalog v2.4.0
   Compiling cesu8 v1.1.0
   Compiling android-tzdata v0.1.1
   Compiling cpufeatures v0.2.12
   Compiling jni-sys v0.3.0
   Compiling aes v0.8.3
   Compiling chrono v0.4.33
   Compiling crc v3.0.1
   Compiling eax v0.5.0
   Compiling hex v0.4.3
   Compiling regex v1.10.3
   Compiling thiserror-impl v1.0.56
   Compiling mmkv-proc-macro-lib v0.0.3
   Compiling protobuf-support v3.3.0
   Compiling jni v0.21.1
   Compiling protobuf-parse v3.3.0
   Compiling protobuf-codegen v3.3.0
   Compiling mmkv v0.4.3
error: linking with `/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/daniel/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" "-Wl,--version-script=/tmp/rustcBoy0s4/list" "-Wl,--no-undefined-version" "/tmp/rustcBoy0s4/symbols.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.00.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.01.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.02.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.03.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.04.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.05.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.06.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.07.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.08.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.09.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.10.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.11.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.12.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.13.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.14.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.mmkv.3d816cd423c1f61b-cgu.15.rcgu.o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/mmkv-1e3d0426ff020918.1w0ph3q8l4wkhn01.rcgu.o" "-Wl,--as-needed" "-L" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps" "-L" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/debug/deps" "-L" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib" "-Wl,-Bstatic" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libhex-012b89755f41899c.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libchrono-745108963c634ad2.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libnum_traits-1bbebfce8d6a5e5d.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libandroid_tzdata-27a9eb79328e2863.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libiana_time_zone-4d4af78cc8a27354.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libandroid_system_properties-68c1a56180eecfb2.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libjni-f229c74a3b2b071d.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/liblibloading-9d2b49d97862f948.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libjava_locator-a32efc8e68fffda9.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/liblazy_static-f77a9824624e702e.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libglob-e380e78c66ec3018.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libcesu8-62e3132d65605ec2.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/liblog-9da475c0f194a49d.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libcombine-be4cd73bf2becb66.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libmemchr-a3188a65ff51b456.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libbytes-be38ac38a97ed23e.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libjni_sys-74c9732b095c34ff.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libeax-49c03f8ae3d2f51d.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libctr-848bdcd6aed87a0b.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libcmac-c89ec4edb3a2e314.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libdbl-0abc0207ed6cb15b.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libdigest-441521401744e8d2.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libsubtle-a63b60211f96a32a.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libblock_buffer-def98d0ede3fcb32.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libaead-d91869579e3f2744.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libaes-baf79243d77daa54.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libcpufeatures-9f5ffd96afb69eca.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libcipher-653b13b9472b9c90.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libinout-c4fb9aade1178248.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libcrypto_common-e46170d1cec3f466.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libgeneric_array-1e7d21a48aa0b4cf.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libtypenum-b9285e66aea77d22.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/librand_core-c3f4f5101ef4cf43.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libgetrandom-7e8e0f8307760a5b.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/liblibc-daf706e04f03dc54.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libcfg_if-83266f8db88babc2.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libprotobuf-7e40142ada71dd14.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libprotobuf_support-7d813d3c71bdb29a.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libthiserror-b703147a0a281dad.rlib" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/cargo/build/i686-linux-android/debug/deps/libonce_cell-2a85a948e38c9934.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libstd-4d4c09732a9f6d21.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libpanic_unwind-b4ac516b36f33cfe.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libobject-a356ae66a6bb3bd7.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libmemchr-69ed441cd3206cf0.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libaddr2line-d8477ca168eca8f7.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libgimli-0162ed5a6c3c46da.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/librustc_demangle-2f5bf68729373dac.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libstd_detect-baecc0e641d20c1e.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libhashbrown-bdd953a8b7f5bc01.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/librustc_std_workspace_alloc-de7df1c2e1706f4c.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libminiz_oxide-814a2abbb028f70c.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libadler-6fae193b7b2592db.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libunwind-478d5539390cc312.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libcfg_if-19bd73690330cb77.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/liblibc-bf3ce65cb8adc5df.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/liballoc-23a22eb3349644aa.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/librustc_std_workspace_core-764ab8049cf6ffaa.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libcore-1a5ebd4bcc70939c.rlib" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib/libcompiler_builtins-1378273580590113.rlib" "-Wl,-Bdynamic" "-ldl" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-linux-android/lib" "-o" "/home/daniel/Documentos/mobile/react-native-mmkv-rs/android/.cxx/Debug/2p293z2m/x86/./cargo/build/i686-linux-android/debug/deps/libmmkv-1e3d0426ff020918.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: ld: error: unable to find library -llog
          clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

Bellow is my CmakeLists file:

cmake_minimum_required(VERSION 3.4.1)
project(MmkvRs)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 11)

include(FetchContent)

FetchContent_Declare(
    Corrosion
    GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
    GIT_TAG v0.4 # Optionally specify a commit hash, version tag or branch here
)
FetchContent_MakeAvailable(Corrosion)

corrosion_import_crate(MANIFEST_PATH ../rust-mmkv/Cargo.toml)

add_library(react-native-mmkv-rs            SHARED
            ../cpp/react-native-mmkv-rs.cpp
            cpp-adapter.cpp
)

target_link_libraries(react-native-mmkv-rs PUBLIC rust-mmkv)

# Specifies a path to native header files.
include_directories(
            ../cpp
)

You haven't given much relevant detail but the important line is this ld: error: unable to find library -llog. Your code want a library called log that it can't find.

It's possibly because of this line, but I just skimmed the code react-native-mmkv/android/CMakeLists.txt at 8ca6ae5d72baa2e981e447570f440e2c479668fe · mrousavy/react-native-mmkv · GitHub

Unfortunately adding those lines to CmakeLists don't works either, i am trying to use a rust lib on a turbomodule package for android native, so far i have only created a simple function on rust to call it from the c++ code.

#[no_mangle]
pub extern "C" fn multiply(x: f64, y: f64) -> f64 {
    x * y
}

It compiles with no problem and the app starts, but for this lib i wold like to use a crate called mmkv crates.io: Rust Package Registry, but as soon as this crate is added to the Cargo.toml file it starts to fail with the message "ld: error: unable to find library -llog" and everything i have tried to incude it on the build just fails

Do you know what the library called log is and why you need it? If you are unsure, try removing the following code:

find_library(log-lib log)

target_link_libraries(
        reactnativemmkv
        core                # <-- MMKV core
        ${log-lib}          # <-- Logcat logger
        ReactAndroid::jsi   # <-- JSI
        android             # <-- Android JNI core
)

I am not using the react-native-mmkv as a base, i only included the log lib to try to resolve the compilation error, removing the lib wont work either, it seams the mmkv crate or one of its dependencies requires it.

liblog is how you do logging on Android. It's one of the most basic Android libraries and should come with all releases of NDK, even oldest ones.

I am using ndk 25.1.8937393 i have already tried versions 20, 21, and 22 and every version resulted on the same error so i set it back to 25.

Thanks, in that case, the linking problem sounds like it should be reproducible with just CPP and Cmake without Rust.

I was able to reproduce the error without android studio by running sh cargo build --target armv7-linux-androideabi --target i686-linux-android --target x86_64-linux-android --target aarch64-linux-android, as expected the compiler fails with the message saying it was not possible to locate llog. Then i tried to run specify the linker to be used by each architecture on .cargo/config.toml, that way i was able to compile to all specified architectures.

Content of my config file:

[target.aarch64-linux-android]
linker = "/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang"

[target.armv7-linux-androideabi]
linker = "/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang"

[target.i686-linux-android]
linker = "/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang"

[target.x86_64-linux-android]
linker = "/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang"

But for some reason the build using android studio still fails, it seams that the config file is ignored and "/home/daniel/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" is used as default. Someone knows if its possible to make android studio use the linker specified on the cargo config file?

I fixed the error by including the NO_LINKER_OVERRIDE flag when including my crate on the cmakelist file, that way the compiler will use the linker specified on the config file.

corrosion_import_crate(MANIFEST_PATH ../rust-mmkv/Cargo.toml NO_LINKER_OVERRIDE)
2 Likes