arm-linux-androideabi-gcc 无法创建可执行文件 - 为 android armeabi 设备编译 ffmpeg
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12660043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
arm-linux-androideabi-gcc is unable to create an executable - compile ffmpeg for android armeabi devices
提问by Chaitanya Chandurkar
I am trying to compile ffmpeg for android armeabi devices.
I am following tutorial by roman10.net
His given build script builds ffmpeg for armv7-a devices. I want to build it for armeabi.
我正在尝试为 android armeabi 设备编译 ffmpeg。
我正在学习 roman10.net 的教程,
他给定的构建脚本为 armv7-a 设备构建了 ffmpeg。我想为 armeabi 构建它。
My ultimate aim is to run ffmpeg commands on android armeabi and armv7-a devices.
我的最终目标是在 android armeabi 和 armv7-a 设备上运行 ffmpeg 命令。
So I change the script's CPU part from
所以我将脚本的 CPU 部分从
#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
to
到
#arm v6
CPU=armv6
OPTIMIZE_CFLAGS="-marm -march=$CPU"
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
(I thought changing it to armv6 would build ffmpeg compatible with armeabi devices. m I wrong?)
(我认为将其更改为 armv6 会构建与 armeabi 设备兼容的 ffmpeg。我错了吗?)
Doubt 1:
Do I also have to change toolchain?
i.e from arm-linux-androideabi-4.4.3to arm-eabi-4.4.0?????
疑点一:
我是否也必须更改工具链?
即从arm-linux-androideabi-4.4.3到arm-eabi-4.4.0?????
Doubt 2:
疑问二:
When I try running ./build.sh (without changing toolchain) it gives me following error:
当我尝试运行 ./build.sh (不更改工具链)时,它给了我以下错误:
/home/chaitanya/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc is unable to create an executable file.
C compiler test failed.
If you think configure made a mistake,.. blaah blahh blaah
after that I got lot of warnings saying:
‘sub_id' is deprecated and many other function deprecated warnings.
在那之后,我收到了很多警告说:
“sub_id”已被弃用,许多其他函数已弃用警告。
platform: ubuntu 11.10
ffmpeg version: 0.11.2
NDK: android-ndk-r5b
平台:ubuntu 11.10
ffmpeg 版本:0.11.2
NDK:android-ndk-r5b
Here is my build script:
这是我的构建脚本:
#!/bin/bash
######################################################
# 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=~/android/android-ndk-r5b
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
function build_one
{
./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" \
--disable-everything \
--enable-demuxer=mov \
--enable-demuxer=h264 \
--disable-ffplay \
--enable-protocol=file \
--enable-avformat \
--enable-avcodec \
--enable-decoder=rawvideo \
--enable-decoder=mjpeg \
--enable-decoder=h263 \
--enable-decoder=mpeg4 \
--enable-decoder=h264 \
--enable-parser=h264 \
--disable-network \
--enable-zlib \
--disable-avfilter \
--disable-avdevice \
$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 libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
#arm v6
CPU=armv6
OPTIMIZE_CFLAGS="-marm -march=$CPU"
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
#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
#arm v7n
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon
#build_one
#arm v6+vfp
#CPU=armv6
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
#PREFIX=./android/${CPU}_vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
How do I tackle this problem? what is going wrong?
我该如何解决这个问题?出了什么问题?
采纳答案by William Seemann
I'm not sure if this is what you are looking but I created a script in order to build FFmpeg 0.11.1 for Android. I modified the scripts provided with older Bambuser FFmpeg builds in order to get them working with 0.11.1. I'm currently using this script to build FFmpeg in my own application so I know the build works. The script located at http://servestream.sourceforge.net/build-ffmpeg.sh. I'm using android-ndk-r8b and Ubuntu 12.04 (x64) to do the building. In order to use the script do the following:
我不确定这是否是您要查找的内容,但我创建了一个脚本以便为 Android 构建 FFmpeg 0.11.1。我修改了旧 Bambuser FFmpeg 版本提供的脚本,以便让它们与 0.11.1 一起使用。我目前正在使用这个脚本在我自己的应用程序中构建 FFmpeg,所以我知道构建工作。该脚本位于http://servestream.sourceforge.net/build-ffmpeg.sh。我正在使用 android-ndk-r8b 和 Ubuntu 12.04 (x64) 进行构建。要使用脚本,请执行以下操作:
1.) Download the script
2.) Open the script and modify the PACKAGE variable to match application's package
3.) Make it executable: chmod +x build-ffmpeg.sh
4.) Set the NDK variable used by the script, for example: export NDK=/home/user/android-ndk-r8b
5.) Run the script: ./build-ffmpeg.sh
1.) 下载脚本
2.) 打开脚本并修改 PACKAGE 变量以匹配应用程序的包
3.) 使其可执行:chmod +x build-ffmpeg.sh
4.) 设置脚本使用的 NDK 变量,例如: export NDK=/home/user/android-ndk-r8b
5.) 运行脚本:./build-ffmpeg.sh
The compiled binaries will be located in the newly created "final-builds" folder in the current working directory. (Note: the script builds binaries for armeabi, armeabi-v7a and x86 architectures)
编译后的二进制文件将位于当前工作目录中新创建的“final-builds”文件夹中。(注意:该脚本为 armeabi、armeabi-v7a 和 x86 架构构建二进制文件)
I hope this answers your question.
我希望这回答了你的问题。
UPDATE:
更新:
If script isn't found, http://sourceforge.net/p/servestream/code/HEAD/tree/ffmpeg/scripts/arm-build.sh
如果找不到脚本,http://sourceforge.net/p/servestream/code/HEAD/tree/ffmpeg/scripts/arm-build.sh
回答by Monty
I finally found the problem with my setup when facing this same issue... Looking at the arm-build.sh script, I started following the script. Notice the "TOOLCHAIN=..." path.
当我面临同样的问题时,我终于发现了我的设置问题......查看 arm-build.sh 脚本,我开始遵循该脚本。注意“TOOLCHAIN=...”路径。
Originally the path was:
TOOLCHAIN=echo $NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/*-x86
原来的路径是:TOOLCHAIN=echo $NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/*-x86
When I went to verify this path exists, I noticed that it did not. I think the reason is that I have a 64-bitbuild.
当我去验证这条路径是否存在时,我注意到它没有。我认为原因是我有一个64 位版本。
My path is actually: .../toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64
我的路径实际上是:.../toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64
What I ended up doing was copying the folder, and renaming it to "linux-x86" and now all is compiling.
我最终做的是复制文件夹,并将其重命名为“linux-x86”,现在一切都在编译。
Hope this helps someone!
希望这可以帮助某人!
回答by Andrew Orobator
In my case, I was trying to build exoplayer's ffmpeg extension. It's not able to build with current versions of the NDK (gcc was removed in NDK 18b), so you have to revert to NDK 15c.
就我而言,我试图构建 exoplayer 的 ffmpeg 扩展。它无法使用当前版本的 NDK(gcc 已在 NDK 18b 中删除)进行构建,因此您必须恢复到 NDK 15c。
回答by Devesh
I got a similar error (C compiler test failed) while trying to build ffmpeg using r8d ndk version and also r8b.
在尝试使用 r8d ndk 版本和 r8b 构建 ffmpeg 时,我遇到了类似的错误(C 编译器测试失败)。
The problem I later found out was that "Extract here" option on latest ubuntu seems to have some bug. It does not extract everything. So, using 'tar -jxf ' extracts properly and you will see more executables in the bin folder.
我后来发现的问题是最新 ubuntu 上的“在此处提取”选项似乎有一些错误。它不会提取所有内容。因此,使用 'tar -jxf ' 可以正确提取,您将在 bin 文件夹中看到更多可执行文件。
You could check this out for reference. http://code.google.com/p/android/issues/detail?id=41187
你可以看看这个以供参考。 http://code.google.com/p/android/issues/detail?id=41187