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

Fail to Build Phi-3 in android #442

Open
Vinaysukhesh98 opened this issue Jun 12, 2024 · 5 comments
Open

Fail to Build Phi-3 in android #442

Vinaysukhesh98 opened this issue Jun 12, 2024 · 5 comments

Comments

@Vinaysukhesh98
Copy link

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:buildCMakeDebug[x86_64]'.

com.android.ide.common.process.ProcessException: ninja: Entering directory `/Documents/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/.cxx/Debug/5b2k5l27/x86_64'
[1/1] Linking CXX shared library Documents/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/build/intermediates/cxx/Debug/5b2k5l27/obj/x86_64/libgenai.so
FAILED: Documents/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/build/intermediates/cxx/Debug/5b2k5l27/obj/x86_64/libgenai.so
: &&Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=x86_64-none-linux-android27 --sysroot=/home/mbuhyd/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o /Documents/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/build/intermediates/cxx/Debug/5b2k5l27/obj/x86_64/libgenai.so CMakeFiles/genai.dir/native-lib.cpp.o -LDocuments/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && :
ld: error: /home/mbuhyd/Documents/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime-genai.so is incompatible with elf_x86_64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

C++ build system [build] failed while executing:
/Android/Sdk/cmake/3.22.1/bin/ninja
-C
/Documents/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/.cxx/Debug/5b2k5l27/x86_64
genai
from Documents/vinay/onnxruntime-inference-examples/mobile/examples/phi-3/android/app

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 1s
61 actionable tasks: 4 executed, 57 up-to-date

@AkulRT
Copy link

AkulRT commented Jun 13, 2024

Facing something similar:

Task :app:buildCMakeDebug[x86_64] FAILED
C/C++: ninja: Entering directory `C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app.cxx\Debug\21d3o5m7\x86_64'
C/C++: cmd.exe /C "cd . && C:\Users\akula\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android27 --sysroot=C:/Users/akula/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so" CMakeFiles/genai.dir/native-lib.cpp.o -LC:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && cd ."
C/C++: ld: error: C:/Users/akula/Desktop/Akul/SCHOOL
1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime-genai.so is incompatible with elf_x86_64
C/C++: ld: error: C:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime.so is incompatible with elf_x86_64
C/C++: clang++: error: linker command failed with exit code 1 (use -v to see invocation)
C/C++: ninja: build stopped: subcommand failed.
cmd.exe /C "cd . && C:\Users\akula\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android27 --sysroot=C:/Users/akula/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so" CMakeFiles/genai.dir/native-lib.cpp.o -LC:/Users/akula/Desktop/Akul/SCHOOL
1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && cd ."

ld: error: C:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU~1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime-genai.so is incompatible with elf_x86_64

cmd.exe /C "cd . && C:\Users\akula\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android27 --sysroot=C:/Users/akula/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so" CMakeFiles/genai.dir/native-lib.cpp.o -LC:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU~1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && cd ."

ld: error: C:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU~1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime.so is incompatible with elf_x86_64

cmd.exe /C "cd . && C:\Users\akula\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android27 --sysroot=C:/Users/akula/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so" CMakeFiles/genai.dir/native-lib.cpp.o -LC:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU~1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && cd ."

clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Execution failed for task ':app:buildCMakeDebug[x86_64]'.

com.android.ide.common.process.ProcessException: ninja: Entering directory `C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app.cxx\Debug\21d3o5m7\x86_64'
[1/2] Building CXX object CMakeFiles/genai.dir/native-lib.cpp.o
[2/2] Linking CXX shared library "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so"
FAILED: C:/Users/akula/Desktop/Akul/School Stuff/Internship/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/build/intermediates/cxx/Debug/21d3o5m7/obj/x86_64/libgenai.so
cmd.exe /C "cd . && C:\Users\akula\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android27 --sysroot=C:/Users/akula/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so" CMakeFiles/genai.dir/native-lib.cpp.o -LC:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && cd ."
ld: error: C:/Users/akula/Desktop/Akul/SCHOOL
1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime-genai.so is incompatible with elf_x86_64
ld: error: C:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU~1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime.so is incompatible with elf_x86_64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

  • Try:

Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:buildCMakeDebug[x86_64]'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:148)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:146)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:134)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:78)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:331)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:318)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.lambda$execute$0(DefaultTaskExecutionGraph.java:314)
    at org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:80)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:314)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
    Caused by: org.gradle.internal.UncheckedException: com.android.ide.common.process.ProcessException: ninja: Entering directory `C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app.cxx\Debug\21d3o5m7\x86_64'
    [1/2] Building CXX object CMakeFiles/genai.dir/native-lib.cpp.o
    [2/2] Linking CXX shared library "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so"
    FAILED: C:/Users/akula/Desktop/Akul/School Stuff/Internship/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/build/intermediates/cxx/Debug/21d3o5m7/obj/x86_64/libgenai.so
    cmd.exe /C "cd . && C:\Users\akula\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android27 --sysroot=C:/Users/akula/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so" CMakeFiles/genai.dir/native-lib.cpp.o -LC:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && cd ."
    ld: error: C:/Users/akula/Desktop/Akul/SCHOOL
    1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime-genai.so is incompatible with elf_x86_64
    ld: error: C:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU~1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime.so is incompatible with elf_x86_64
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.

C++ build system [build] failed while executing:
@echo off
"C:\Users\akula\AppData\Local\Android\Sdk\cmake\3.22.1\bin\ninja.exe" ^
-C ^
"C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\.cxx\Debug\21d3o5m7\x86_64" ^
genai
from C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:68)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:128)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:248)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:73)
at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:233)
at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:216)
at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:199)
at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:166)
at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:105)
at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:44)
at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:59)
at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:56)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:78)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:56)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44)
at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:67)
at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:37)
at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41)
at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74)
at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:50)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:28)
at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.executeDelegateBroadcastingChanges(CaptureStateAfterExecutionStep.java:100)
at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:72)
at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:50)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:40)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:29)
at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:179)
at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:70)
at org.gradle.internal.Either$Right.fold(Either.java:175)
at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59)
at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:68)
at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:46)
at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:36)
at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:25)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)
at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:91)
at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:55)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:37)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:65)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:36)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:77)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:38)
at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:108)
at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:55)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:71)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:45)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.executeWithNonEmptySources(SkipEmptyWorkStep.java:177)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:81)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:53)
at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:32)
at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:21)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:36)
at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:23)
at org.gradle.internal.execution.steps.CleanupStaleOutputsStep.execute(CleanupStaleOutputsStep.java:75)
at org.gradle.internal.execution.steps.CleanupStaleOutputsStep.execute(CleanupStaleOutputsStep.java:41)
at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.lambda$execute$2(ExecuteWorkBuildOperationFiringStep.java:66)
at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.execute(ExecuteWorkBuildOperationFiringStep.java:66)
at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.execute(ExecuteWorkBuildOperationFiringStep.java:38)
at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:32)
at org.gradle.api.internal.tasks.execution.TaskExecution$4.withWorkspace(TaskExecution.java:293)
at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30)
at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:21)
at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37)
at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27)
at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:47)
at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:34)
at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:64)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:145)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:134)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:78)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:331)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:318)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.lambda$execute$0(DefaultTaskExecutionGraph.java:314)
at org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:80)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:314)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
Caused by: com.android.ide.common.process.ProcessException: ninja: Entering directory `C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app.cxx\Debug\21d3o5m7\x86_64'
[1/2] Building CXX object CMakeFiles/genai.dir/native-lib.cpp.o
[2/2] Linking CXX shared library "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so"
FAILED: C:/Users/akula/Desktop/Akul/School Stuff/Internship/onnxruntime-inference-examples/mobile/examples/phi-3/android/app/build/intermediates/cxx/Debug/21d3o5m7/obj/x86_64/libgenai.so
cmd.exe /C "cd . && C:\Users\akula\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android27 --sysroot=C:/Users/akula/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libgenai.so -o "C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\build\intermediates\cxx\Debug\21d3o5m7\obj\x86_64\libgenai.so" CMakeFiles/genai.dir/native-lib.cpp.o -LC:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64 -lonnxruntime-genai -lonnxruntime -landroid -llog -latomic -lm && cd ."
ld: error: C:/Users/akula/Desktop/Akul/SCHOOL
1/INTERN1/ONNXRU1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime-genai.so is incompatible with elf_x86_64
ld: error: C:/Users/akula/Desktop/Akul/SCHOOL1/INTERN1/ONNXRU~1/mobile/examples/phi-3/android/app/src/main/cpp/../jniLibs/x86_64/libonnxruntime.so is incompatible with elf_x86_64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

C++ build system [build] failed while executing:
@echo off
"C:\Users\akula\AppData\Local\Android\Sdk\cmake\3.22.1\bin\ninja.exe" ^
-C ^
"C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app\.cxx\Debug\21d3o5m7\x86_64" ^
genai
from C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app
at com.android.build.gradle.internal.cxx.process.ExecuteProcessKt.execute(ExecuteProcess.kt:288)
at com.android.build.gradle.internal.cxx.process.ExecuteProcessKt$executeProcess$1.invoke(ExecuteProcess.kt:108)
at com.android.build.gradle.internal.cxx.process.ExecuteProcessKt$executeProcess$1.invoke(ExecuteProcess.kt:106)
at com.android.build.gradle.internal.cxx.timing.TimingEnvironmentKt.time(TimingEnvironment.kt:32)
at com.android.build.gradle.internal.cxx.process.ExecuteProcessKt.executeProcess(ExecuteProcess.kt:106)
at com.android.build.gradle.internal.cxx.process.ExecuteProcessKt.executeProcess$default(ExecuteProcess.kt:85)
at com.android.build.gradle.internal.cxx.build.CxxRegularBuilder.executeProcessBatch(CxxRegularBuilder.kt:332)
at com.android.build.gradle.internal.cxx.build.CxxRegularBuilder.build(CxxRegularBuilder.kt:129)
at com.android.build.gradle.tasks.ExternalNativeBuildTask$doTaskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:70)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
at com.android.build.gradle.tasks.ExternalNativeBuildTask.doTaskAction(ExternalNativeBuildTask.kt:145)
at com.android.build.gradle.internal.tasks.UnsafeOutputsTask$taskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:65)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
at com.android.build.gradle.internal.tasks.UnsafeOutputsTask.taskAction(UnsafeOutputsTask.kt:63)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
... 118 more
Caused by: com.android.ide.common.process.ProcessException: Error while executing process C:\Users\akula\AppData\Local\Android\Sdk\cmake\3.22.1\bin\ninja.exe with arguments {-C C:\Users\akula\Desktop\Akul\School Stuff\Internship\onnxruntime-inference-examples\mobile\examples\phi-3\android\app.cxx\Debug\21d3o5m7\x86_64 genai}
at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:73)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:48)
at com.android.build.gradle.internal.cxx.process.ExecuteProcessKt.execute(ExecuteProcess.kt:277)
... 135 more
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\akula\AppData\Local\Android\Sdk\cmake\3.22.1\bin\ninja.exe'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:431)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:46)
... 136 more

BUILD FAILED in 50s
33 actionable tasks: 33 executed

@XantaKross
Copy link

Same error.

@XantaKross
Copy link

XantaKross commented Jun 15, 2024

Guys, I figured out the cause. The error is caused due to that the Generate() API and thus the libonnxruntime-genai.so file is not compatible with x86-64 architecture. Which is the architecture of your PC which is running android emulator. However, generally android devices use ARM architecture which is what the Generate API in this android app is compiled for. Thus due to the mismatch of the architectures, this app is expecting and the one you are running it this leads to the above error.

To fix it:

  1. Connect your PC to a physical android device/mobile

  2. Enable USB Debugging on your Android device
    Go to "Settings" > "Developer options" (If you don't see "Developer options", go to "About phone" and tap the "Build number" seven times to enable Developer options).
    Enable "USB debugging" in the Developer options.

  3. Connect android device to PC. On device click "Allow USB debugging" from your computer. Tap "OK" to allow it.

  4. In android studio,
    Go to "Tools" > "Device Manager" (or click the device icon in the toolbar).
    If your device is listed, you're all set. If not, try:
    -> Click on "Install device drivers" and follow the prompts.
    or
    ->Restart the Android Device Manager and your device should appear.

  5. Click Run -> Run App and deploy your app to your android device.

Hope it helps!

@AkulRT
Copy link

AkulRT commented Jun 17, 2024

Hi Xanta,

Thank you for the advice. Unfortunately I don't have a physical device to run this on. I am currently downloading an ARM system image, will try on that and see if I am successful.

@herriojr
Copy link

herriojr commented Sep 13, 2024

it looks like the .so libraries under the x86_64 dir are actually arm and not x86_64

this is what it should be like (ff7ee24):

➜  android git:(ff7ee24) file app/src/main/jniLibs/x86_64/libonnxruntime.so
app/src/main/jniLibs/x86_64/libonnxruntime.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0dc8563635b1c756aced07b345a2a67e82315a1b, stripped

this is what their main branch looks like:

➜  android git:(main) file app/src/main/jniLibs/x86_64/libonnxruntime.so
app/src/main/jniLibs/x86_64/libonnxruntime.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=9d07eacfa2e7b0d01055a2f4b5ec94b3f0dbb470, stripped

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

4 participants