MNN icon indicating copy to clipboard operation
MNN copied to clipboard

Android手机上shell仿真测试,.so可以调起vulkan但.a失败

Open CloudGuardian opened this issue 1 year ago • 7 comments

平台(如果交叉编译请再附上交叉编译目标平台):

Platform(Include target platform as well if cross-compiling):

在ubuntu上编译,跑在Android手机shell,64位

Github版本:

Github Version:

MNN-2.8.1.zip 24/1/3

直接下载ZIP包请提供下载日期以及压缩包注释里的git版本(可通过7z l zip包路径命令并在输出信息中搜索Comment 获得,形如Comment = bc80b11110cd440aacdabbf59658d630527a7f2b)。 git clone请提供 git commit 第一行的commit id

Provide date (or better yet, git revision from the comment section of the zip. Obtainable using 7z l PATH/TO/ZIP and search for Comment in the output) if downloading source as zip,otherwise provide the first commit id from the output of git commit

编译方式:

Compiling Method

请在这里粘贴cmake参数或使用的cmake脚本路径以及完整输出
Paste cmake arguments or path of the build script used here as well as the full log of the cmake proess here or pastebin
修改配置vim CMakeLists.txt如下 :
option(MNN_BUILD_SHARED_LIBS "MNN build shared or static lib" OFF)
option(MNN_SEP_BUILD "Build MNN Backends and expression separately. Only works with MNN_BUILD_SHARED_LIBS=ON" OFF)
option(MNN_OPENCL "Enable OpenCL" ON)
option(MNN_VULKAN "Enable Vulkan" ON)
option(MNN_ARM82 "Enable ARM82" ON)

linux下编译:
./schema/generate.sh
cd project/android
mkdir build_64 && cd build_64 && ../build_64.sh

编译日志:

Build Log:

粘贴在这里
Paste log here or pastebin
编译正常无报错

编译静态库和动态库均没有报错,在Android shell下,.so库可使用openCL和Vulkan,.a库可使用OpenCL但使用不了Vulkan,提示如下: image

如果在ScheduleConfig中添加:.backupType = MNN_FORWARD_VULKAN,则提示无法创建Runtime,如下: image

此前类似问题中提出的解决方法: ~ 编译添加完全链接:GCC: -Wl,--whole-archive MNN -Wl,--no-whole-archive ~ 编译关闭 MNN_SEP_BUILD 均有尝试,但仍不解决问题

已检查手机平台GPU是支持Vulkan接口的,是否和Android手机权限有关?但为什么libMNN_Vulkan.so却可以调起Vulkan呢? 谢谢😛

CloudGuardian avatar Apr 12 '24 03:04 CloudGuardian

应该还是 faq 里面说的那个问题,没有链接注册函数:

  • 编译添加完全链接:GCC: -Wl,--whole-archive MNN -Wl,--no-whole-archive 这个是对你的最终可执行文件添加。可以搜下 android 上面对应的完全链接

jxt1234 avatar Apr 12 '24 09:04 jxt1234

应该还是 faq 里面说的那个问题,没有链接注册函数:

  • 编译添加完全链接:GCC: -Wl,--whole-archive MNN -Wl,--no-whole-archive 这个是对你的最终可执行文件添加。可以搜下 android 上面对应的完全链接

应该还是 faq 里面说的那个问题,没有链接注册函数:

  • 编译添加完全链接:GCC: -Wl,--whole-archive MNN -Wl,--no-whole-archive 这个是对你的最终可执行文件添加。可以搜下 android 上面对应的完全链接

请问中间这个MNN是指什么呢?

CloudGuardian avatar Apr 15 '24 02:04 CloudGuardian

就是原先你的程序是 -l MNN

改成 -Wl,--whole-archive MNN -Wl,--no-whole-archive

jxt1234 avatar Apr 15 '24 12:04 jxt1234

就是原先你的程序是 -l MNN

改成 -Wl,--whole-archive MNN -Wl,--no-whole-archive

jxt1234 avatar Apr 15 '24 12:04 jxt1234

就是原先你的程序是 -l MNN

改成 -Wl,--whole-archive MNN -Wl,--no-whole-archive

我原先程序中没有-l MNN 🤣 我的Android.mk中的mnn库链接和编译选项如下: include $(CLEAR_VARS) LOCAL_MODULE := libmnn ifeq ($(TARGET_ARCH_ABI), arm64-v8a) LOCAL_SRC_FILES := $(LOCAL_MNN_LIB_PATH_EXT)/arm64-v8a/libMNN.a endif ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) LOCAL_SRC_FILES := $(LOCAL_MNN_LIB_PATH_EXT)/armeabi-v7a/libMNN.a endif include $(PREBUILT_STATIC_LIBRARY)

LOCAL_CFLAGS += -pie -fPIE LOCAL_LDFLAGS += -pie -fPIE -lc -lm -Wl,--gc-sections -fuse-ld=lld -Wl,-Bsymbolic

CloudGuardian avatar Apr 16 '24 01:04 CloudGuardian

不了解 Android.mk 怎么实现 .a 符号的全链接,可以网上搜搜看

jxt1234 avatar Apr 16 '24 08:04 jxt1234

已解决🆗

CloudGuardian avatar May 22 '24 08:05 CloudGuardian

Marking as stale. No activity in 60 days.

github-actions[bot] avatar Jul 21 '24 09:07 github-actions[bot]