android / ndk

The Android Native Development Kit
2.01k stars 257 forks source link

[BUG] Android NDK r25 gives me incompatible errors when compiling FFmpeg with libvvdec library. #1859

Closed MartinEesmaa closed 1 year ago

MartinEesmaa commented 1 year ago

Description

Hello everyone, I have a problem using latest Android NDK r25c. When I tried to compile libvvdec with FFmpeg before mpv build and it gave error of my own repository FFmpeg configuration in ffbuild/config.log:

ld: error: /home/martineesmaa/mpv-android-vvc/buildscripts/prefix/arm64/lib/libvvdec.a(vvdec.cpp.o) is incompatible with aarch64linux
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: libvvdec >= 1.6.0 not found using pkg-config

Here is my CMAKE command configurations and built success before my FFmpeg configuration came error:

cmake \
       -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
            -DCMAKE_TOOLCHAIN_FILE=${HOME}/mpv-android-vvc/buildscripts/sdk/android-ndk-r25c/build/cmake/android.toolchain.cmake \
                -DANDROID_STL=c++_shared -DVVDEC_ENABLE_LINK_TIME_OPT=OFF -DANDROID_PLATFORM=android-21 \
            -DCMAKE_INSTALL_PREFIX=$prefix_dir ..

My steps before I got error on FFmpeg during mpv build:

  1. Git clone my own mpv repository git clone --depth=1 https://github.com/MartinEesmaa/mpv-android-vvc -b gpu-next
  2. Download required dependencies & SDK tools using ./download.sh in buildscripts folder.
  3. Give scripts permission access and edit deps/fdkaac/libSBRdec/src/lpp_tran.cpp to remove three ANDROID inlines.
  4. Build using ./buildall.sh --arch arm64 mpv.

For Android NDK r24 works well without having issues, but now my android ndk r25c having issues. Is it maybe NDK or compiler bug?

Affected versions

r25

Canary version

No response

Host OS

Linux

Host OS version

Ubuntu 22.04 LTS

Affected ABIs

All affected ABIs

Build system

CMake

Other build system

No response

minSdkVersion

21

Device API level

21

DanAlbert commented 1 year ago

https://developer.android.com/ndk/guides/cmake

-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a

That's spelled wrong for the NDK toolchain file. -DANDROID_ABI=arm64-v8a. Does that fix the problem? I don't think the toolchain file tries to interpret CMake's own interface.

-DCMAKE_SYSTEM_NAME=Android

This is unnecessary when using the NDK toolchain file. Probably asymptomatic though.

MartinEesmaa commented 1 year ago

@DanAlbert, thank you for your response. I think it fixed to detect FFmpeg configuration now by your help of -DANDROID_ABI=arm64-v8a. Thanks, I will close the issue.