1

最近我正在用 ndk 为 android 编译 ffmpeg,我在这篇文章中这样做(http://vec.io/posts/how-to-build-ffmpeg-with-android-ndk)。configure是对的,但是当我开始制作时,它会出错。配置外壳:

export TMPDIR=D:/temp/android
export NDK=/cygdrive/D/DevelopKit/android-ndk-r8d
export PATH=/cygdrive/C/cygwin/tmp/ffmpeg/bin:$PATH
export CC=arm-linux-androideabi-gcc
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar
export C_INCLUDE_PATH=/cygdrive/C/cygwin/tmp/ffmpeg/sysroot/usr/include
export LIBRARY_PATH=/cygdrive/C/cygwin/tmp/ffmpeg/sysroot/usr/lib
CFLAGS="-O3 -Wall -mthumb -pipe -fpic -fasm \
  -finline-limit=300 -ffast-math \
  -fstrict-aliasing -Werror=strict-aliasing \
  -fmodulo-sched -fmodulo-sched-allow-regmoves \
  -Wno-psabi -Wa,--noexecstack \
  -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__ \
  -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ \
  -DANDROID -DNDEBUG"

EXTRA_CFLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-quad"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"

FFMPEG_FLAGS="--prefix=/tmp/ffmpeg/build \
  --target-os=linux \
  --arch=arm \
  --enable-cross-compile \
  --cross-prefix=arm-linux-androideabi- \
  --enable-shared \
  --disable-symver \
  --disable-doc \
  --disable-ffplay \
  --disable-ffmpeg \
  --disable-ffprobe \
  --disable-ffserver \
  --disable-avdevice \
  --disable-avfilter \
  --disable-encoders  \
  --disable-muxers \
  --disable-filters \
  --disable-devices \
  --disable-everything \
  --enable-protocols  \
  --enable-parsers \
  --enable-demuxers \
  --disable-demuxer=sbg \
  --enable-decoders \
  --enable-bsfs \
  --enable-network \
  --enable-swscale  \
  --enable-asm \
  --enable-version3"

./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS"

配置结果(config.mak 的一部分):

ifndef FFMPEG_CONFIG_MAK
FFMPEG_CONFIG_MAK=1
FFMPEG_CONFIGURATION=--prefix=/tmp/ffmpeg/build --target-os=linux --arch=arm --enable-cross-compile --cross-prefix=arm-linux-androideabi- --enable-shared --disable-symver --disable-doc --disable-ffplay --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-avdevice --disable-avfilter --disable-encoders --disable-muxers --disable-filters --disable-devices --disable-everything --enable-protocols --enable-parsers --enable-demuxers --disable-demuxer=sbg --enable-decoders --enable-bsfs --enable-network --enable-swscale --enable-asm --enable-version3 --extra-cflags='-O3 -Wall -mthumb -pipe -fpic -fasm   -finline-limit=300 -ffast-math   -fstrict-aliasing -Werror=strict-aliasing   -fmodulo-sched -fmodulo-sched-allow-regmoves   -Wno-psabi -Wa,--noexecstack   -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__   -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__   -DANDROID -DNDEBUG -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-quad' --extra-ldflags='-Wl,--fix-cortex-a8'
prefix=/tmp/ffmpeg/build
LIBDIR=$(DESTDIR)${prefix}/lib
SHLIBDIR=$(DESTDIR)${prefix}/lib
INCDIR=$(DESTDIR)${prefix}/include
BINDIR=$(DESTDIR)${prefix}/bin
DATADIR=$(DESTDIR)${prefix}/share/ffmpeg
MANDIR=$(DESTDIR)${prefix}/share/man
SRC_PATH=.
ifndef MAIN_MAKEFILE
SRC_PATH:=$(SRC_PATH:.%=..%)
endif
CC_IDENT=gcc 4.6
 (GCC)
ARCH=arm
CC=arm-linux-androideabi-gcc
CXX=arm-linux-androideabi-g++
AS=arm-linux-androideabi-gcc
LD=arm-linux-androideabi-gcc
DEPCC=arm-linux-androideabi-gcc
DEPCCFLAGS= $(CPPFLAGS)
DEPAS=arm-linux-androideabi-gcc
DEPASFLAGS= $(CPPFLAGS)
YASM=yasm
DEPYASM=yasm
AR=arm-linux-androideabi-ar
ARFLAGS=rc
AR_O=$@

但是当我成功的时候

CC  libavformat/4xm.o
In file included from ./libavutil/bswap.h:35:0,
                 from ./libavutil/intreadwrite.h:25,
                 from libavformat/4xm.c:30:
./config.h:8:18: warning: missing terminating " character [enabled by default]
In file included from ./libavutil/bswap.h:35:0,
                 from ./libavutil/intreadwrite.h:25,
                 from libavformat/4xm.c:30:
./config.h:9:7: warning: missing terminating " character [enabled by default]
./config.h:9:2: error: missing terminating " character
In file included from ./libavutil/intreadwrite.h:25:0,
                 from libavformat/4xm.c:30:
./libavutil/bswap.h:58:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static'
common.mak:48: recipe for target `libavformat/4xm.o' failed
make: *** [libavformat/4xm.o] Error 1

这是字符错误,我猜它是 windows 字符(我使用的是 cygwin),我尝试了 dos2unix 但它没有用。请帮助我并感谢您的建议。

4

1 回答 1

2

编辑 ./config.h 并删除换行符

#define CC_IDENT "gcc 4.6 (GCC)"
于 2013-03-01T13:05:10.220 回答