如何在Android应用程序中构建ffmpeg?

时间:2014-03-24 11:43:14

标签: android android-ndk ffmpeg

通过下面的步骤成功构建ffmpeg

  http://stackoverflow.com/questions/22471514/ffmpeg-build-output-is-not-showing

  Now I have copy include and all .a file into my JNI folder. and my Android.mk 
  file is as:-



      LOCAL_PATH := $(call my-dir)

        include $(CLEAR_VARS)

        LOCAL_MODULE    := ffmpegutils
       LOCAL_SRC_FILES := tutorial02.c

      LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
      LOCAL_LDLIBS := -L$(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm/usr/lib -L$(LOCAL_PATH) -lavformat -lavcodec  -lavfilter -lavutil -lswscale -llog -ljnigraphics -lz -ldl -lgcc

include $(BUILD_SHARED_LIBRARY)

但我的项目错误如下: -

     Description    Resource    Path    Location    Type
make: *** [obj/local/armeabi/libffmpegutils.so] Error 1 MainActivity            C/C++ Problem
undefined reference to 'ANativeWindow_unlockAndPost'    MainActivity        line 231, external location: /home/kiwitech/Documents/development/tools/ndk/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/ffmpegutils/tutorial02.o: in function decodeAndRender:jni/tutorial02.c   C/C++ Problem
undefined reference to 'ANativeWindow_lock' MainActivity        line 222, external location: /home/kiwitech/Documents/development/tools/ndk/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/ffmpegutils/tutorial02.o: in function decodeAndRender:jni/tutorial02.c   C/C++ Problem
undefined reference to 'ANativeWindow_release'  MainActivity        line 150, external location: /home/kiwitech/Documents/development/tools/ndk/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/ffmpegutils/tutorial02.o: in function naSetSurface:jni/tutorial02.c  C/C++ Problem
undefined reference to 'ANativeWindow_setBuffersGeometry'   MainActivity        line 147, external location: /home/kiwitech/Documents/development/tools/ndk/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/ffmpegutils/tutorial02.o: in function naSetSurface:jni/tutorial02.c  C/C++ Problem
undefined reference to 'ANativeWindow_fromSurface'  MainActivity        line 145, external location: /home/kiwitech/Documents/development/tools/ndk/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/ffmpegutils/tutorial02.o: in function naSetSurface:jni/tutorial02.c  C/C++ Problem

请有人帮助我。

1 个答案:

答案 0 :(得分:6)

你也必须链接到android库,所以将-landroid添加到你的LOCAL_LDLIBS。

$ NDK / docs下的文件STABLE-APIS.html解释:

  

所有相应的功能都由API级别9附带的“libandroid.so”库版本提供。要使用它,请使用以下命令:       LOCAL_LDLIBS + = -landroid