Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you spend time to help me to resolve error in build .so file? #12

Open
badpaybad opened this issue Jun 27, 2023 · 3 comments
Open

Comments

@badpaybad
Copy link

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;
}

@asimsharf
Copy link

#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;
}

@asimsharf
Copy link

gcc -c -fPIC *.c
gcc -shared -o liball.so *.o
nm -D liball.so

@badpaybad
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants