cunarist / rinf

Rust for native business logic, Flutter for flexible and beautiful GUI
MIT License
1.96k stars 69 forks source link

library "libc++_shared.so" not found #210

Closed tiendvlp closed 11 months ago

tiendvlp commented 11 months ago

Report

Hi, just try to build my project with some Rust library and I come up with this error, please help library "libc++_shared.so" not found

This issue only come when I add this dependencies to my cargo.toml

surrealdb = { version = "1.0.0", features = ["kv-mem", "kv-speedb"] }

And when I run my project, it got stuck on ensureInitialized function

E/flutter (32057): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libhub.so': dlopen failed: library "libc++_shared.so" not found: needed by /data/app/~~_aGWOzzB5QeHuev8CR6kHw==/com.devlogs.game.test.game_test-vlrr6ZIENhAbmpAHeEUJgQ==/base.apk!/lib/arm64-v8a/libhub.so in namespace classloader-namespace
E/flutter (32057): #0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43)
E/flutter (32057): #1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12)
E/flutter (32057): #2      loadNativeLibrary (package:rinf/src/ffi.dart:12:27)
E/flutter (32057): #3      api (package:rinf/src/ffi.dart:6:31)
E/flutter (32057): #4      api (package:rinf/src/ffi.dart)
E/flutter (32057): #5      Rinf.ensureInitialized (package:rinf/rinf.dart:27:11)
E/flutter (32057): #6      main (package:game_test/main.dart:6:14)
E/flutter (32057): #7      _runMain.<anonymous closure> (dart:ui/hooks.dart:157:23)
E/flutter (32057): #8      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:296:19)
E/flutter (32057): #9      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
E/flutter (32057): 

I also try to add these option to build.gradle file, but nothing change

      externalNativeBuild {
            cmake {
                cppFlags ""
                arguments "-DANDROID_STL=c++_shared"
            }

Steps to Reproduce

System Information

Please provide the output from the command below, using markdown codeblock syntax.

rustc --version
rustc 1.71.1 (eb26296b5 2023-08-03)

protoc --version
libprotoc 3.20.3

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.8, on macOS 13.4.1 22F82 darwin-arm64, locale en)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.84.0)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
temeddix commented 11 months ago

Hi @tiendvlp , thank you for your report :)

I'm not sure if this issue is directly related with Rinf. Could you verify that cargo build works, first? It can possibly be an issue with C libraries of surrealdb.

tiendvlp commented 11 months ago

Hi @temeddix after put this in both android/../build.gradle file and rinf/build.gradle file, it working now, so we can close this issue

 externalNativeBuild {
            cmake {
                cppFlags ""
                arguments "-DANDROID_STL=c++_shared"
            }