Describe the issue
The Android build does not support building a libonnxruntime_providers_qnn.so, but this functionality is needed to use the new plug-in style usage.
The following is a proposed patch to support building qnn EP as a shared library for Android.
diff --git a/cmake/onnxruntime_providers_cpu.cmake b/cmake/onnxruntime_providers_cpu.cmake
index f6efcb3..3935edb 100644
--- a/cmake/onnxruntime_providers_cpu.cmake
+++ b/cmake/onnxruntime_providers_cpu.cmake
@@ -217,7 +217,6 @@ set_target_properties(onnxruntime_providers PROPERTIES FOLDER "ONNXRuntime")
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS|tvOS"
- AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
file(GLOB onnxruntime_providers_shared_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/shared/*.h"
@@ -240,7 +240,11 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
# On Apple/Unix we don't directly link with this library as we load it with RTLD_GLOBAL, so this is only set to the actual library on WIN32
# But, in exchange we need to manually add Boost::mp11 to include dirs for every EP.
# It is because "provider_api.h" includes core/framework/op_kernel.h which includes op_kernel.h which includes "boost/mp11.hpp"
- set(ONNXRUNTIME_PROVIDERS_SHARED)
+ if(ANDROID)
+ set(ONNXRUNTIME_PROVIDERS_SHARED onnxruntime_providers_shared)
+ else()
+ set(ONNXRUNTIME_PROVIDERS_SHARED)
+ endif()
if(APPLE)
set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -exported_symbols_list ${ONNXRUNTIME_ROOT}/core/providers/shared/exported_symbols.lst")
diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py
index 4b23101..be06184 100644
--- a/tools/ci_build/build.py
+++ b/tools/ci_build/build.py
@@ -837,8 +837,8 @@ def generate_build_tree(
if args.use_qnn == "static_lib":
cmake_args += ["-Donnxruntime_BUILD_QNN_EP_STATIC_LIB=ON"]
- if args.android and args.use_qnn != "static_lib":
- raise BuildError("Only support Android + QNN builds with QNN EP built as a static library.")
+ # if args.android and args.use_qnn != "static_lib":
+ # raise BuildError("Only support Android + QNN builds with QNN EP built as a static library.")
if args.use_qnn == "static_lib" and args.enable_generic_interface:
raise BuildError("Generic ORT interface only supported with QNN EP built as a shared library.")
Urgency
No response
Target platform
Android
Build script
python3 tools/ci_build/build.py
--cmake_extra_defines "CMAKE_VERBOSE_MAKEFILE=ON"
--cmake_extra_defines "CMAKE_C_FLAGS=$extra_cflags"
--cmake_extra_defines "CMAKE_CXX_FLAGS=$extra_cflags"
--build_dir "$build_dir"
--config $build_type
--build_shared_lib
--parallel
$ANDROID_FLAGS
--use_cache
--skip_tests
--no_kleidiai
$@
python3 tools/ci_build/build.py \
--cmake_extra_defines "CMAKE_VERBOSE_MAKEFILE=ON" \
--cmake_extra_defines "CMAKE_C_FLAGS=$extra_cflags" \
--cmake_extra_defines "CMAKE_CXX_FLAGS=$extra_cflags" \
--build_dir "$build_dir" \
--config $build_type \
--build_shared_lib \
--parallel \
$ANDROID_FLAGS \
--use_cache \
--skip_tests \
--no_kleidiai \
--use_qnn \
--qnn_home="$QNN_SDK" \
--target onnxruntime_providers_qnn
Error / output
The first error is:
"Only support Android + QNN builds with QNN EP built as a static library."
After that, then we need to get the libonnxruntime_providers_shared.so built also.
Visual Studio Version
No response
GCC / Compiler Version
No response
Describe the issue
The Android build does not support building a libonnxruntime_providers_qnn.so, but this functionality is needed to use the new plug-in style usage.
The following is a proposed patch to support building qnn EP as a shared library for Android.
Urgency
No response
Target platform
Android
Build script
python3 tools/ci_build/build.py
--cmake_extra_defines "CMAKE_VERBOSE_MAKEFILE=ON"
--cmake_extra_defines "CMAKE_C_FLAGS=$extra_cflags"
--cmake_extra_defines "CMAKE_CXX_FLAGS=$extra_cflags"
--build_dir "$build_dir"
--config $build_type
--build_shared_lib
--parallel
$ANDROID_FLAGS
--use_cache
--skip_tests
--no_kleidiai
$@
Error / output
The first error is:
"Only support Android + QNN builds with QNN EP built as a static library."
After that, then we need to get the libonnxruntime_providers_shared.so built also.
Visual Studio Version
No response
GCC / Compiler Version
No response