flutter_programs
flutter_programs copied to clipboard
Could you spend time to help me to resolve error in build .so file?
I try write my own C code Then load using this ffi:
// load by manual copy to folder android/src/main/jniLibs final dylib1 = ffi.DynamicLibrary.open("libsimpleso.so");
Then got these error. Did I got problem when use cmake to build .so file
E/flutter ( 4013): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libsimpleso.so': dlopen failed: library "libc.so.6" not found E/flutter ( 4013): #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43) E/flutter ( 4013): #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12)
Code C just simple bellow.
#include <stdio.h>
void hello_world_1()
{
printf("Hello World\n");
}
int sum_1(int a, int b)
{
printf("c called sum\n");
return a + b;
}
#include <stdio.h>
void hello_world_1();
int sum_1(int a, int b);
int main(void){
int a = 4, b = 5;
// call hello wolrd 1
hello_world_1();
// call sum_1
sum_1(a, b);
return 0;
}
void hello_world_1()
{
printf("Hello World\n");
}
int sum_1(int a, int b)
{
printf("c called sum\n");
return a + b;
}
gcc -c -fPIC *.c gcc -shared -o liball.so *.o nm -D liball.so
Thanks but here is my case.
https://github.com/badpaybad/flutter-audio-cutting/tree/main/lib/interop/simpleclang I use cmake to build then copy to android/app/src/main/jniLibs/x86_64/libsimpleso.so in void main
final dylib1 = ffi.DynamicLibrary.open("libsimpleso.so");
I got error above
Other case worked well but need modify android/app/build.gradle
android {
externalNativeBuild {
cmake {
path "../../lib/interop/helloclang/CMakeLists.txt"
}
}
So I guess that I use cmake to build using CMakeLists.txt was wrong
Could you give me some help?
this is git with source PoC: https://github.com/badpaybad/flutter-audio-cutting