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

[ffi] pthread_mutex_t variable defined in main causing dlopen failed: cannot locate symbol error #1070

Open
pangz-lab opened this issue Apr 4, 2024 · 2 comments

Comments

@pangz-lab
Copy link

I loaded the pre-compiled libmylib.so including the libc++_shared.so in flutter android.
Inside the main.cpp
I have a variable defined like the following.

pthread_mutex_t stratum_work_lock;

I created the ffi for main only.
int main(int argc, char *argv[])
When running the .so file, I got this error
dlopen failed: cannot locate symbol "stratum_sock_lock"

I wonder what's causing the error or if I'm missing something.

I only need to exposed the main method as it's all I need to call.
Any pointers would be appreciated.

@pangz-lab pangz-lab changed the title [ffi] pthread_mutex_t vairable defined in main causing dlopen failed: cannot locate symbol error [ffi] pthread_mutex_t variable defined in main causing dlopen failed: cannot locate symbol error Apr 4, 2024
@dcharkes
Copy link
Collaborator

dcharkes commented Apr 4, 2024

It sounds like the dynamic linker tries to find the required symbol during dlopen and can't find the one.

Did you declare but not define the variable? https://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-declaration

@pangz-lab
Copy link
Author

Thank you for the response. The variable is declared and defined.

The binary was working as expected using the Process library but the equivalent .so file is not. At first the DynamicLibrary complained that the libc++_shared.so cannot be found. Then I added the one from Android NDK, after running again, this is the error I got.

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