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

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

Open
CloudGuardian opened this issue Apr 12, 2024 · 7 comments
Open
Labels
question Further information is requested

Comments

@CloudGuardian
Copy link

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

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呢?
谢谢😛

@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 12, 2024

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

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

@jxt1234 jxt1234 added the question Further information is requested label Apr 12, 2024
@CloudGuardian
Copy link
Author

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

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

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

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

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

@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 15, 2024

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

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

1 similar comment
@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 15, 2024

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

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

@CloudGuardian
Copy link
Author

就是原先你的程序是 -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

@jxt1234
Copy link
Collaborator

jxt1234 commented Apr 16, 2024

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

@CloudGuardian
Copy link
Author

已解决🆗

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

No branches or pull requests

2 participants