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

打包apk时报错:C/C++: ld: error: ncnn-20220216/build-android-armv7/install/lib/libncnn.a(mat_pixel_android.cpp.o) is incompatible with aarch64linux #41

Open
yumingchen opened this issue Aug 6, 2022 · 4 comments

Comments

@yumingchen
Copy link

C/C++: ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(mat_pixel_android.cpp.o) is incompatible with aarch64linux

Execution failed for task ':app:buildCMakeRelWithDebInfo[arm64-v8a]'.

Build command failed.
Error while executing process /usr/bin/ninja with arguments {-C /media/cym/CYM/CLionProjects/NCNN/ncnn-android-yolov5/app/.cxx/RelWithDebInfo/121p3v4c/arm64-v8a yolov5ncnn}
ninja: Entering directory `/media/cym/CYM/CLionProjects/NCNN/ncnn-android-yolov5/app/.cxx/RelWithDebInfo/121p3v4c/arm64-v8a'
[1/2] Building CXX object CMakeFiles/yolov5ncnn.dir/yolov5ncnn_jni.cpp.o
[2/2] Linking CXX shared library /media/cym/CYM/CLionProjects/NCNN/ncnn-android-yolov5/app/build/intermediates/cxx/RelWithDebInfo/121p3v4c/obj/arm64-v8a/libyolov5ncnn.so
FAILED: /media/cym/CYM/CLionProjects/NCNN/ncnn-android-yolov5/app/build/intermediates/cxx/RelWithDebInfo/121p3v4c/obj/arm64-v8a/libyolov5ncnn.so
: && /home/cym/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android24 --sysroot=/home/cym/Android/Sdk/ndk/25.0.8775105/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 -O2 -g -DNDEBUG -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libyolov5ncnn.so -o /media/cym/CYM/CLionProjects/NCNN/ncnn-android-yolov5/app/build/intermediates/cxx/RelWithDebInfo/121p3v4c/obj/arm64-v8a/libyolov5ncnn.so CMakeFiles/yolov5ncnn.dir/yolov5ncnn_jni.cpp.o /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a -ljnigraphics -fopenmp -static-openmp /home/cym/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/libvulkan.so /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libglslang.a /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libSPIRV.a /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libMachineIndependent.a /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libOGLCompiler.a /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libOSDependent.a -pthread /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libGenericCodeGen.a -landroid -ljnigraphics -llog -latomic -lm && :
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(allocator.cpp.o) is incompatible with aarch64linux
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(benchmark.cpp.o) is incompatible with aarch64linux
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(gpu.cpp.o) is incompatible with aarch64linux
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(layer.cpp.o) is incompatible with aarch64linux
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(mat.cpp.o) is incompatible with aarch64linux
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(net.cpp.o) is incompatible with aarch64linux
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(option.cpp.o) is incompatible with aarch64linux
ld: error: /media/cym/CYM/CLionProjects/NCNN/ncnn-20220216/build-android-armv7/install/lib/libncnn.a(mat_pixel_android.cpp.o) is incompatible with aarch64linux
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

在虚拟设备能展示界面,但是打包apk时保了错。看了下貌似没有生成libyolov5ncnn.so,不明觉厉。
求大佬指点!!!

@Ayers-github
Copy link

Ayers-github commented Sep 7, 2022

我也是同样的错误:
Build command failed.
Error while executing process D:\sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C C:\Users\Administrator\Desktop\ncnn-android-yolov5-master\app.cxx\cmake\debug\arm64-v8a yolov5ncnn}
ninja: Entering directory C:\Users\Administrator\Desktop\ncnn-android-yolov5-master\app\.cxx\cmake\debug\arm64-v8a' [1/1] Linking CXX shared library C:\Users\Administrator\Desktop\ncnn-android-yolov5-master\app\build\intermediates\cmake\debug\obj\arm64-v8a\libyolov5ncnn.so FAILED: C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/build/intermediates/cmake/debug/obj/arm64-v8a/libyolov5ncnn.so cmd.exe /C "cd . && D:\sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android24 --gcc-toolchain=D:/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/sdk/ndk/21.4.7075529/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 -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libyolov5ncnn.so -o C:\Users\Administrator\Desktop\ncnn-android-yolov5-master\app\build\intermediates\cmake\debug\obj\arm64-v8a\libyolov5ncnn.so CMakeFiles/yolov5ncnn.dir/yolov5ncnn_jni.cpp.o C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libncnn.a -ljnigraphics -fopenmp -static-openmp D:/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/24/libvulkan.so C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libglslang.a C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libSPIRV.a C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libMachineIndependent.a C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libOGLCompiler.a C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libOSDependent.a -pthread C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libGenericCodeGen.a -landroid -ljnigraphics -llog -latomic -lm && cd ." C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libncnn.a(gpu.cpp.o): In function ncnn::VulkanDevicePrivate::destroy_dummy_buffer_image()':
gpu.cpp:(.text._ZN4ncnn19VulkanDevicePrivate26destroy_dummy_buffer_imageEv+0x20): undefined reference to __aarch64_ldadd4_acq_rel' gpu.cpp:(.text._ZN4ncnn19VulkanDevicePrivate26destroy_dummy_buffer_imageEv+0x74): undefined reference to __aarch64_ldadd4_acq_rel'
gpu.cpp:(.text._ZN4ncnn19VulkanDevicePrivate26destroy_dummy_buffer_imageEv+0xc4): undefined reference to __aarch64_ldadd4_acq_rel' C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libncnn.a(gpu.cpp.o): In function ncnn::VulkanDevicePrivate::~VulkanDevicePrivate()':
gpu.cpp:(.text._ZN4ncnn19VulkanDevicePrivateD2Ev[_ZN4ncnn19VulkanDevicePrivateD2Ev]+0x28): undefined reference to __aarch64_ldadd4_acq_rel' gpu.cpp:(.text._ZN4ncnn19VulkanDevicePrivateD2Ev[_ZN4ncnn19VulkanDevicePrivateD2Ev]+0x78): undefined reference to __aarch64_ldadd4_acq_rel'
C:/Users/Administrator/Desktop/ncnn-android-yolov5-master/app/src/main/jni/ncnn-20220729-android-vulkan/arm64-v8a/lib/libncnn.a(gpu.cpp.o):gpu.cpp:(.text._ZN4ncnn19VulkanDevicePrivateD2Ev[_ZN4ncnn19VulkanDevicePrivateD2Ev]+0xc8): more undefined references to `__aarch64_ldadd4_acq_rel' follow
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

@Chopin68
Copy link

我也是这个错误,请问你们解决了吗

@Chopin68
Copy link

我也是这个错误,请问你们解决了吗

我通过更换到ncnn-20201218-android-vulkan成功编译

@efinal
Copy link

efinal commented Nov 8, 2022

我也是类似的错误,通过更换NDK版本搞定。
注意,每个ncnn-xxxx-android-vulkan 都有一个对应的NDK版本,在它的release notes里面有写,例如ncnn-20220729-android-vulkan对应的是android-ndk-r24,所以下载对应版本的NDK,在project structure里面设置好,就好了

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