Khang-NT / ffmpeg-binary-android

FFmpeg Prebuilt Android
192 stars 72 forks source link

Added NDK Unified headers support https://android.googlesource.com/pl… #10

Open ivanarh opened 6 years ago

ivanarh commented 6 years ago

The script doesn't work with modern NDK version. My commit fixes it. See https://android.googlesource.com/platform/ndk/+/ndk-release-r16/docs/UnifiedHeaders.md

Khang-NT commented 6 years ago

Seem like we also need to change $SYSROOT:

The compile time sysroot is now $NDK/sysroot

And:

At link time, change nothing. All link time build behavior should match the deprecated headers behavior. --sysroot should still point to $NDK/platforms/android-$API/arch-$ARCH/

How we can change sysroot only at compile time? Does the new script build success in your machine? Or maybe we will consider to update NDK version to r15:

In r15 unified headers are used by default. In r16, the old headers have been removed.

ivanarh commented 6 years ago

Script is successfully run on my machine with MacOS X Sierra, Android NDK r16b, all architectures. But i ran only "full" build and missed a check for "lite" build. Unfortunately it fails due to problems with mmap system call:

/opt/android-sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc -I. -I./ --sysroot=/opt/android-sdk/ndk-bundle/platforms/android-16/arch-arm/ -isystem /opt/android-sdk/ndk-bundle/sysroot/usr/include -isystem /opt/android-sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=16  --sysroot=/opt/android-sdk/ndk-bundle/platforms/android-16/arch-arm/ -isysroot /opt/android-sdk/ndk-bundle/platforms/android-16/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -mfloat-abi=softfp -marm -march=armv7-a -Os -O3   -I/Users/user/src/openshot/ffmpeg-binary-android/build_scripts/build_dir/include --sysroot=/opt/android-sdk/ndk-bundle/platforms/android-16/arch-arm/ -fPIE -isystem /opt/android-sdk/ndk-bundle/sysroot/usr/include -isystem /opt/android-sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=16    -march=armv7-a -std=c11 -fomit-frame-pointer -fPIC -marm -pthread -I/Users/user/src/openshot/ffmpeg-binary-android/build_scripts/build_dir/include/opus -I/Users/user/src/openshot/ffmpeg-binary-android/build_scripts/build_dir/include -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Os -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized  -MMD -MF libavdevice/dv1394.d -MT libavdevice/dv1394.o -c -o libavdevice/dv1394.o libavdevice/dv1394.c
libavdevice/dv1394.c: In function 'dv1394_read_header':
libavdevice/dv1394.c:103:16: error: call to 'mmap' declared with attribute error: mmap is not available with _FILE_OFFSET_BITS=64 when using GCC until android-21. Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or switch to Clang.
     dv->ring = mmap(NULL, DV1394_PAL_FRAME_SIZE * DV1394_RING_FRAMES,
                ^
make: *** [libavdevice/dv1394.o] Error 1

It requires either switching to clang or discarding 16 API level support. I would prefer the first variant, do you mind?

ivanarh commented 6 years ago

How we can change sysroot only at compile time?

It's quite tricky and, i think, it doesn't make sense at all. Adding -isystem flag with sysroot/include path is absolutely sufficient.

Or maybe we will consider to update NDK version to r15:

May be you mean downgrade?

Khang-NT commented 6 years ago

+1 It's cool if we migrate to Clang and NDK r16.