Hi, Guys,
I compiled a shared object using mali GPU. But when linking it to produce an application I got an error:.../libGLES_mali.so:unknown CPU architecture.The CFLAGES is -mcpu=cortex-a15 -O2.
What's wrong? I need some help.
Best Regards!
That normally happens if your build is picking up host GCC rather than a cross-compiled version one part of the build (i.e. building an ARM library and trying to link with x86 tools, or visa-versa).
It is possible to share a small reproducer? It's hard to provide more specific help without seeing your whole build sequence.
Thanks,
Pete
I use a cross-compiled version gcc(arm-linux-androideabi-gcc) on both of the building and link stage. Some code of makefile as follows:
building phase:
= -mcpu=cortex-a15 -O2
....
LIBS += -lGLES_mali
MKDIRPATH = c:/cygwin/bin/
link phase:
NDK_PREFIX := $(NDK_BASE)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-
CC := $(NDK_PREFIX)gcc
test:$(OBJECTS)
Phenix
Hi Phenix,
Just to be clear, you're using the Android toolchains, but not the NDK build system itself? I.e. you don't have an Android.mk that you build with ndk-build? Is this intended to be run on Android or linux?
If you could share a reproducer then we could be of more help. Off the top of my head I would check the libGLES_mali.so with "file" and "readelf" to check it makes sense, then take a look at any objects output from the compile stage to see if there are any obvious problems. Maybe one is built for ARM and the other for THUMB. Maybe you need to pass -march=arm.
Hth,
Chris
Makes sense that it is imcompatible if libGLES_mali.so is built for ARM. Just need to work out why the arm-linux-androideabi compiler doesn't want to link with it
I have built a binary that links against libGLES_mail. I compiled it on Intel Core(TM) platform to run it on the ARM and the toolchain was a corss-platform version (android-ndk-r10c/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-gcc-4.9). The libGLES_mail.so I got is from a device with platform mt6752.
In addtion, today I exchanged the gcc version to an x64 version (android-ndk-r10c/toolchains/aarch64-linux-android-4.9/prebuilt/windows/bin/aarch64-linux-android-gcc-4.9).The error "unknown CPU architecture" was gone instead of an "skip incompatible -lCLES_mali" error.
In addtion, today I exchanged the gcc version to an x64 version (android-ndk-r10c/toolchains/aarch64-linux-android-4.9/prebuilt/windows/bin/aarch64-linux-android-gcc-4.9)
Note that that is a compiler for the 64-bit version of the ARM architecture (i.e. it emits 64-bit binaries for ARM), not an x64 host 32-bit compiler.
HTH, Pete
Hi Chris,
Thanks.I use ndk-build to build an executable program,then run it on android using adb.I have also tried to pass -march=arm. It got the same error.
Thx,
Aha, Pete's message made me do a bit more digging. The SoC you pulled that lib from is 64 bit, i.e. AArch64, so that explains why the arm-linux-androideabi compiler does not recognise the architecture. I'm not sure why the AArch64 compiler skips it however. That said, if you're using ndk-build then there's generally no reason to be pointing the build system to any particular compiler in your Android.mk file. Is there any particular reason you don't just set APP-ABI := arm64-v8a in your Application.mk file, and let the build system pick the right compiler for you? The examples that come with the NDK should serve as examples of this.
arm64-v8a in your Application.mk file, and let the build system pick the right compiler for you? The examples that come with the NDK should serve as examples of this.