The environment

  • Ubuntu 16.04 LTS
  • The NDK 16.1.4479499

Ref

  • Thor: Simplest ffMPEg-based mobile example: Android HelloWorld
  • Yuiop: Compile and port FFmpeg library with Android Studio

All kinds of error

  • No such file or directory
Unknown option "".
See ./configure --help foravailable options. ./build_android.sh: 22: ./build_android.sh: - cross - prefix = / home/maple/Android/Sdk/the NDK - bundle/toolchains/arm - Linux - androideabi - 4.9 / prebuilt/Linux - x86_64 / bin/arm - Lin ux-androideabi-: not found CC libavfilter/aeval.o In file included from libavfilter/aeval.c:26:0: ./libavutil/avassert.h:30:20: fatal error: stdlib.h: No such file or directory#include <stdlib.h>
                    ^
compilation terminated.
common.mak:60: recipe for target 'libavfilter/aeval.o' failed
make: *** [libavfilter/aeval.o] Error 1
CC	libavfilter/aeval.o
In file included from libavfilter/aeval.c:26:0:
./libavutil/avassert.h:30:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^
compilation terminated.
common.mak:60: recipe for target 'libavfilter/aeval.o' failed
make: *** [libavfilter/aeval.o] Error 1
 
Copy the code

In fact, the keyword is No such file or directory. Generally are from the blog copy invisible characters (eg: space, carriage return) caused by, because everyone’s OS is not the same, the system of these characters may be different encoding, so it is recommended to open the display of various Spaces in the plain text editing software, so that it can be less puzzling pit. Take the upstream yuiop blog as an example, his system for MAC, compile FFmpeg script shell as:

#! /bin/sh
NDK=/home/maple/Android/Sdk/ndk-bundle
SYSROOT=$NDK/platforms/android-18/arch-arm
TOOLCHAIN=$NDK/ toolchains/arm - Linux - androideabi - 4.9 / prebuilt/Linux - x86_64 = arm CPU PREFIX = $(pwd)/android/$CPU
ADDI_CFLAGS="-marm"

build_one() {
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-doc \
--disable-symver \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}

build_one
Copy the code

Editing in Ubuntu will result in errors. Type a blank line for each line in the build_one function, like:

#! /bin/sh
NDK=/home/maple/Android/Sdk/ndk-bundle
SYSROOT=$NDK/platforms/android-18/arch-arm
TOOLCHAIN=$NDK/ toolchains/arm - Linux - androideabi - 4.9 / prebuilt/Linux - x86_64 = arm CPU PREFIX = $(pwd)/android/$CPU
ADDI_CFLAGS="-marm"

build_one() {

./configure \

--prefix=$PREFIX \

--enable-shared \

--disable-static \

--disable-doc \

--disable-ffmpeg \

--disable-ffplay \

--disable-ffprobe \

--disable-ffserver \

--disable-avdevice \

--disable-doc \

--disable-symver \

--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \

--target-os=linux \

--arch=arm \

--enable-cross-compile \

--sysroot=$SYSROOT \

--extra-cflags="-Os -fpic $ADDI_CFLAGS" \

--extra-ldflags="$ADDI_LDFLAGS" \

$ADDITIONAL_CONFIGURE_FLAG

make clean

make

make install

}

build_one
Copy the code
  • NDK ‘File format not recognized’
maple@maple-All-Series:~/AndroidStudioProjects/FFmpegDemo/app/src/main/jni$ /home/maple/Android/Sdk/ndk-bundle/ndk-build  APP_ALLOW_MISSING_DEPS=true
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.    
Android NDK: WARNING: APP_PLATFORM android-14 is higher than android:minSdkVersion 1 in/home/maple/AndroidStudioProjects/FFmpegDemo/app/src/main/AndroidManifest.xml. NDK binaries will *not* be comptible with  devices older than android-14. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.mdfor more information.    
/home/maple/Android/Sdk/ndk-bundle/build/core/setup-app.mk:81: Android NDK: Application targets deprecated ABI(s): armeabi    
/home/maple/Android/Sdk/ndk-bundle/build/core/setup-app.mk:82: Android NDK: Support for these ABIs will be removed ina future NDK release. /home/maple/Android/Sdk/ndk-bundle/build/core/build-binary.mk:693: Android NDK: Module sffhelloworld depends on undefined modules: avdevice postproc [armeabi] Install : libavcodec-57.so => libs/armeabi/libavcodec-57.so / home/maple/Android/Sdk/the NDK - bundle/toolchains/arm - Linux - androideabi - 4.9 / prebuilt/Linux - x86_64 / bin/arm - Linux - androideabi - strip:/home/maple/AndroidStudioProjects/FFmpegDemo/app/src/main/libs/armeabi/libavcodec-57.so: File format not recognized make: *** [/home/maple/AndroidStudioProjects/FFmpegDemo/app/src/main/libs/armeabi/libavcodec-57.so] Error 1 make: *** Deleting file `/home/maple/AndroidStudioProjects/FFmpegDemo/app/src/main/libs/armeabi/libavcodec-57.so'
Copy the code

Same old, Dont Panic. ‘File format not recognized’, so let’s look at what format it is, and that requires a File command.

Using the file command, you can detect the type of a given file. The file command can be used to check the file system, magic magic number, and language.

maple@maple-All-Series:~/AndroidStudioProjects/FFmpegDemo/app/src/main/jni$ file libavcodec-57.so 
libavcodec-57.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=8de4e7be651e4db057b11d72e33fffd8d19d40dd, stripped
Copy the code

So is of type x86-64, so application. mk should look like this:

APP_ABI :=x86
Copy the code

Write that first, and I’ll fill it in when I get a new one. Click “like” if it helps 🙂