1. 下载 android-ndk-r7-linux-x86.tar.bz2
解压到/works/sdk/ 目录
~/.bashrc中设定环境变量:
export PATH=$PATH:/works/sdk/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
export PATH=$PATH:/works/sdk/android-sdk-linux/tools
2. 下载 ffmpeg-0.10.tar.gz
2.1 解压后 修改源文件
修改文件libavdevice/v4l.c,在
#include <linux/videodev.h> 之上增加2行:
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
2.2 在源文件目录建立 build_android.sh
2.3 将 ffmpeg-0.10 改名为 jni, 并在改名后的jni目录建立 Android.mk
ndk-build V=1
这时候会出错:arm-linux-androideabi-g++: /works/cong/obj/local/armeabi/ffmpeg: No such file or directory
将Android.mk 中 LOCAL_MODULE := ffmpeg 改为LOCAL_MODULE := ffmpeg_234
再次编译出现一大堆连接错误,Android.mk实在不熟悉只能手动执行: 在打印出来的 arm-linux-androideabi-g++ 的选项中加入 -L../libs/ -lffmpeg.
ok,编译通过
build_andriod.sh
- #!/bin/bash
-
- ######################################################
- # FFmpeg builds script for Android+ARM platform
- #
- # This script is released under term of
- # CDDL (http://www.opensource.org/licenses/cddl1)
- # Wrote by pinxue (~@gmail.com) from RockPlayer.com
- # 2010-8 ~ 2011-4
- ######################################################
-
- ######################################################
- # Usage:
- # put this script in top of FFmpeg source tree
- # ./build_android
- #
- # It generates binary for following architectures:
- # ARMv6
- # ARMv6+VFP
- # ARMv7+VFPv3-d16 (Tegra2)
- # ARMv7+Neon (Cortex-A8)
- #
- # Customizing:
- # 1. Feel free to change ./configure parameters for more features
- # 2. To adapt other ARM variants
- # set $CPU and $OPTIMIZE_CFLAGS
- # call build_one
- ######################################################
-
- #NDK=/work/sdk/android-ndk-r7
- NDK=/works/sdk/android-ndk-r7
- PLATFORM=$NDK/platforms/android-8/arch-arm/
- #PREBUILT=../../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3
- PREBUILT=/works/sdk/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
-
-
function build_one
-
{
-
- # -fasm : required. Android header file uses asm keyword instead of __asm__ , but most of c dialect (like ansi,c99,gnu99) implies -fno-asm.
- # ~/android/android-ndk-r4/build/platforms/android-5/arch-arm//usr/include/asm/byteorder.h: In function '___arch__swab32':
- # ~/android/android-ndk-r4/build/platforms/android-5/arch-arm//usr/include/asm/byteorder.h:25: error: expected ')' before ':' token
-
- # -fno-short-enums : optimized. Else FFmpeg obj will generate a huge number of warning for variable-size enums,
- # though we may suppress them by --no-enum-size-warning, it would be better to avoid it.
- # .../ld: warning: cmdutils.o uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
-
- # --extra-libs="-lgcc" : required. Else cannot solve some runtime function symbols
- # ... undefined reference to `__aeabi_f2uiz'
-
- # --enable-protocols : required. Without this option, the file open always fails mysteriously.
- # FFmpeg's av_open_input_file will invoke file format probing functions, but because most of useful demuxers has flag of zero
- # which cause them are ignored during file format probling and fall to url stream parsing,
- # if protocols are disabled, the file:// url cannot be opened as well.
-
- # $PREBUILT/bin/arm-eabi-ar d libavcodec/libavcodec.a inverse.o : required.
- # FFmpeg includes two copies of inverse.c both in libavutil and libavcodec for performance consideration (not sure the benifit yet)
- # Without this step, final ld of generating libffmpeg.so will fail silently, if invoke ld through gcc, gcc will collect more reasonable error message.
-
- # -llog: debug only, FFmpeg itself doesn't require it at all.
- # With this option, we may simply includes "utils/Log.h" and use LOGx() to observe FFmpeg's behavior
- # PS, it seems the toolchain implies -DNDEBUG somewhere, it would be safer to use following syntax
- # #ifdef NDEBUG
- # #undef NDEBUG
- # #define HAVE_NDEBUG
- # #endif
- # #include "utils/Log.h"
- # #ifdef HAVE_NDEBUG
- # #define NDEBUG
- # #undef HAVE_NDEBUG
- # #endif
-
- # --whole-archive : required. Else ld generate a small .so file (about 15k)
-
- # --no-stdlib : required. Android doesn't use standard c runtime but invited its own wheal (bionic libc) because of license consideration.
-
- # space before \ of configure lines: required for some options. Else next line will be merged into previous lines's content and cause problem.
- # Especially the --extra-cflags, the next line will pass to gcc in this case and configure will say gcc cannot create executable.
-
- # many options mentioned by articles over internet are implied by -O2 or -O3 already, need not repeat at all.
-
- # two or three common optimization cflags are omitted because not sure about the trade off yet. invoke NDK build system with V=1 to find them.
-
- # -Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x mentioned by almost every articles over internet, but it is not required to specify at all.
-
- # -Dipv6mr_interface=ipv6mr_ifindex : required. Android inet header doesn't use ipv6mr_interface which is required by rfc, seems it generate this user space header file directly from kernel header file, but Linux kernel has decided to keep its own name for ever and ask user space header to use rfc name.
-
- # HAVE_SYS_UIO_H : required. Else:
- # In file included from ~/android/android-ndk-r4/build/platforms/android-5/arch-arm//usr/include/linux/socket.h:29,
- # from ~/android/android-ndk-r4/build/platforms/android-5/arch-arm//usr/include/sys/socket.h:33,
- # from libavformat/network.h:35,
- # from libavformat/utils.c:46:
- #~/android/android-ndk-r4/build/platforms/android-5/arch-arm//usr/include/linux/uio.h:19: error: redefinition of 'struct iovec'
- #
-
- # --disable-doc : required because of strange bug of toolchain.
-
-
./configure --target-os=linux \
- --prefix=$PREFIX \
- --enable-cross-compile \
- --extra-libs="-lgcc" \
- --arch=arm \
- --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
- --cross-prefix=$PREBUILT/bin/arm-linux-androideabi-\
- --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
- --sysroot=$PLATFORM \
- --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
- --disable-shared \
- --enable-static \
- --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
- --enable-parsers \
- --enable-encoders \
- --enable-decoders \
- --enable-muxers \
- --enable-demuxers \
- --enable-swscale \
- --enable-swscale-alpha \
- --disable-ffplay \
- --disable-ffprobe \
- --disable-ffserver \
- --enable-network \
- --enable-indevs \
- --disable-bsfs \
- --enable-filters \
- --enable-avfilter \
- --enable-protocols \
- --enable-asm \
- $ADDITIONAL_CONFIGURE_FLAG
-
-
- #make clean
- make -j4 install
-
- $PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
- $PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib-soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libavfilter/libavfilter.a libswscale/libswscale.a libavdevice/libavdevice.a libswresample/libswresample.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker /works/sdk/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
-
}
- #$PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/armv7-a/libgcc.a
-
- #不需要编armv6
- #arm v7vfpv3
- CPU=armv7-a
- OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
- PREFIX=./android/$CPU ADDITIONAL_CONFIGURE_FLAG=
- build_one
-
- #arm v7vfp
- CPU=armv7-a
- OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
- PREFIX=./android/$CPU-vfp
- ADDITIONAL_CONFIGURE_FLAG=
- build_one
这个 /works/sdk/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
用的是绝对路径,不太清这个 /works/sdk/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/ 路径下的两个 libgcc.a有什么区别,反正用上面的一个是可以编译成功,而用另一个编译不成功。
android.mk
- LOCAL_PATH:= $(call my-dir)
- include $(CLEAR_VARS)
- #LOCAL_SRC_FILES:= cmdutils.cpp ffmpeg.cpp
- LOCAL_SRC_FILES:= cmdutils.c ffmpeg.c
- LOCAL_C_INCLUDES :=
- LOCAL_SHARED_LIBRARIES := libffmpeg
- #LOCAL_PRELINK_MODULE := false
- LOCAL_MODULE := ffmpeg_234
- include $(BUILD_EXECUTABLE)
不改名为ffmpeg_234 而一直用 ffmpeg是不能编译通过的,不清楚为什么。
分享到:
相关推荐
这个压缩包“android-ndk-r26b-windows.zip”包含了NDK的第26个版本,专为Windows操作系统设计。通过这个工具,开发者可以利用原生代码编写高性能、低级别的应用模块,比如图形处理、物理模拟或音频处理等。 在...
这个“android-ndk-r25b-linux.zip”文件是NDK的一个特定版本,即r25b,专为Linux操作系统设计。在Android应用开发中,NDK扮演着至关重要的角色,它允许开发者使用原生代码(如C和C++)来编写部分应用,以提高性能、...
这个压缩包“android-ndk-r25b-windows.zip”包含了NDK的第25个版本,专为Windows操作系统设计。NDK的主要功能是让开发者能够在Android应用中使用原生代码,例如C、C++,以实现高性能计算或利用硬件加速等功能。 **...
Android-ndk-r23b包含了一系列的编译器、链接器和其他工具,用于将C/C++源代码编译成可以在Android设备上运行的机器码。这个版本可能包含以下组件: 1. **交叉编译工具链**:这些工具链允许你在Windows环境下构建...
android-ndk-r7-windows android-ndk-r7-windows android-ndk-r7-windows
这个“android-ndk-r23b-linux.zip”文件是NDK的一个特定版本,即r23b,专为Linux操作系统设计。在Android应用开发中,NDK扮演着至关重要的角色,它允许开发者使用原生代码(如C和C++)来编写部分应用,以提升性能或...
Ubuntu20系统,Android NDK-r21e 编译 FFmpeg4.2.4; 编译出libavcodec.so libavdevice.so、libavfilter.so、libavformat.so、libavutil.so、libswresample.so、libswscale.so;
在本案例中,我们关注的是"android-ndk-r26b-darwin.zip",这是一个专为macOS系统设计的NDK版本。 **Android NDK的主要功能和用途** 1. **性能优化**:对于计算密集型或图形密集型的应用,如游戏和复杂的科学计算...
这篇教程主要介绍了如何使用`android-ndk-r8b`编译最新版本的FFmpeg,并将其应用于Android应用程序。以下是对整个过程的详细解释: 1. **FFmpeg的安装**: 首先,你需要在Ubuntu 10.04 LTS环境中安装Git,以便克隆...
1、支持arm 2、支持aarch64
./configure --prefix=/usr/local/android --host aarch64-linux-android --with-pic --disable-shared make -j4;make install 在wsl下面用ndk20编译的, aarch64-linux-android29-clang++ aarch64-linux-android-...
这个“android-ndk-r26b-linux.zip”文件是NDK的一个特定版本——R26B,特别为Linux操作系统设计。 NDK的主要功能和知识点包括: 1. **原生库支持**:NDK允许开发者创建原生库,这些库可以直接在设备的CPU上运行,...
`android-ndk-r25b-darwin.zip` 是针对macOS系统的NDK版本,版本号为r25b,包含了一系列用于构建、编译和调试原生代码的工具。 在Android应用开发中,NDK的主要作用和知识点包括: 1. **JNI (Java Native ...
android-ndk-r18b-linux-x86_64.zip https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip
如果你的项目依赖于GCC的某些特性或者你需要继续维护使用GCC编译的旧代码库,"android-ndk-r17c-windows-x86_64.zip" 将是你理想的选项。在升级到更高版本的NDK之前,你需要确保你的代码和依赖项与Clang兼容,或者...
对于64位Windows用户来说,"android-ndk-r20b-windows-x86_64.zip"是一个关键资源,它意味着可以直接在Windows环境中搭建本地开发环境,无需担心系统架构问题。解压后的文件包括了所有必要的工具和库,如编译器、...
echo 'export PATH=$PATH:/opt/android/ndk/android-ndk-r19c' | sudo tee -a ~/.bashrc source ~/.bashrc ``` 现在,NDK已准备就绪。接下来,我们需要安装QT 5.13。访问QT官方网站(https://www.qt.io/download)...
使用压缩包内的“android-ndk-r18b”文件,开发者可以按照官方文档进行安装和配置,然后在Android Studio中集成NDK,通过CMake或ndk-build脚本来编译原生代码。同时,开发者需要注意,虽然NDK提供了许多优势,但过度...
export NDK_PATH=/path/to/your/android-ndk-r25c export TOOLCHAIN=$NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64 export API=21 export HOST_TAG=linux-x86_64 export TARGET=aarch64-none-linux-android...
android-ndk-r7b-windows.part1.rar