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

CANNOT LINK EXECUTABLE on Android #2639

Closed
AndradeMaicon opened this issue Jun 30, 2023 · 7 comments
Closed

CANNOT LINK EXECUTABLE on Android #2639

AndradeMaicon opened this issue Jun 30, 2023 · 7 comments
Labels
platform-android question Further information is requested

Comments

@AndradeMaicon
Copy link

Description

Hi, I followed the guide and build wasmedge for Android but when I try to run an example the runtimer throws the following exception,
"CANNOT LINK EXECUTABLE "./wasmedge": library "libwasmedge.so" not found: needed by main executable".

Please, can you help me understand what I did wrong?

Environment

@hydai
Copy link
Member

hydai commented Jul 1, 2023

Hi @AndradeMaicon
Do you copy all built files on Android?
WasmEdge will build libwasmedge.so (and libwasmedge.0.0.x). The cli tools rely on libwasmedge.so.

@hydai hydai changed the title CANNOT LINK EXECUTABLE CANNOT LINK EXECUTABLE on Android Jul 1, 2023
@hydai hydai added question Further information is requested platform-android labels Jul 1, 2023
@AndradeMaicon
Copy link
Author

Hi @hydai, thanks for answer me;
So I followed every step in the WasmEdge documentation exactly as was. But now I thought this error might have been caused during build and for this reason when I push the wasmedge folder to my Android device this files are missing.

If possible, I would like you to look at the repository I created with the result of my local build (sorry, I know it's not good practice but it's temporary) maybe with your experience you can tell me if there is indeed a problem with mine build.

I'm running ./utils/android/standalone/build_for_android.sh to build and cp -r examples build/tools/wasmedge/examples to copy the artifacts and inside de build folder adb push ./tools/wasmedge /data/local/tmp to push all files to my device.

@hydai
Copy link
Member

hydai commented Jul 6, 2023

The libwasmedge.so is located in <build folder>/lib/api/*.so So it should be copied as well with the wasmedge.

@AndradeMaicon
Copy link
Author

I had already tried this alternative. At first, I had copied the whole folder into /data/local/tmp and in another attempt, I copied it into the wasmedge folder (/data/local/tmp/wasmedge). After your last answer I tried copying just the libwasmedge.so file and repeated the same tests but I keep getting the exact same error.

Do you have another suggestion that I could do?

This is the current log from my adb shell

o1s:/data/local/tmp $ ls -la
total 7875
drwxrwx--x 5 shell shell 3452 2023-07-06 10:12 .
drwxr-x--x 6 root root 3452 2022-01-17 01:21 ..
drwxrwxr-x 5 shell shell 3452 2023-05-19 12:13 .studio
-rwxrwxrwx 1 shell shell 8039408 2023-07-06 10:05 libwasmedge.so
drwxrwxrwx 5 shell shell 3452 2023-05-26 14:48 perfd
drwxrwxr-x 4 shell shell 3452 2023-07-06 10:12 wasmedge
o1s:/data/local/tmp $ cd wasmedge/examples/
o1s:/data/local/tmp/wasmedge/examples $ ../wasmedge hello.wasm 1 2 3
CANNOT LINK EXECUTABLE "../wasmedge": library "libwasmedge.so" not found: needed by main executable

@q82419
Copy link
Collaborator

q82419 commented Jul 10, 2023

You should copy the shared library into your library searching path (such as /usr/local/lib) or use the LD_LIBRARY_PATH environment variable.

@binadamu-isiyoonekana
Copy link

Hi folks.
The easiest way is to link wasmedge (or tools) in a static way. For doing so, you should modify the WasmEdge options (see the main CMakeList.txt file, around line 50 for more information on WasmEdge compilation options) passed in the utils/android/standalone/build_for_android.sh around line 14 by adding the following options:
-DWASMEDGE_BUILD_STATIC_LIB=ON -DWASMEDGE_LINK_TOOLS_STATIC=ON
And then it should be okay.
Ciao

@AndradeMaicon
Copy link
Author

Hi folks. The easiest way is to link wasmedge (or tools) in a static way. For doing so, you should modify the WasmEdge options (see the main CMakeList.txt file, around line 50 for more information on WasmEdge compilation options) passed in the utils/android/standalone/build_for_android.sh around line 14 by adding the following options: -DWASMEDGE_BUILD_STATIC_LIB=ON -DWASMEDGE_LINK_TOOLS_STATIC=ON And then it should be okay. Ciao

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-android question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants