I am working on ffmpeg and i want to write Jni wrapper for ffmpeg to i can call decode_video method of ffmpeg avcodec class.
Swap:SwapFfmpeg swap$ ndk-build
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
Compile thumb : com_example_swapffmpeg_Jffmpeg <= com_example_swapffmpeg_Jffmpeg.c
SharedLibrary : libcom_example_swapffmpeg_Jffmpeg.so
/Users/swap/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin- x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/com_example_swapffmpeg_Jffmpeg/com_example_swapffmpeg_Jffmpeg.o: in function Java_com_example_swapffmpeg_Jffmpeg_videoinfo:jni/com_example_swapffmpeg_Jffmpeg.c:14: error: undefined reference to 'avcodec_register_all'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libcom_example_swapffmpeg_Jffmpeg.so] Error 1
I created android.mk file and into that i link to c wrapper class and libffmpeg.so file.
But when i try to build it display error on avcodec_register_all
i search on google and i found 2 solution
1) one is extern C {} but i am using .C files not C++ so i dont think so i need to use extern {}
2) second is to add
LOCAL_LDLIBS := -L/Users/swap/android-ndk-r9/platforms/arch-arm/usr/lib -L$(LOCAL_PATH) -lavformat -lavcodec -lavdevice -lavfilter -lavutil -lswscale -lz -ldl -lgcc
I have added this into my android.mk and i got this error.anybody can tell me what should i write infornt of Local_LDLIBS and why to write that?
/Users/swap/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/com_example_swapffmpeg_Jffmpeg/com_example_swapffmpeg_Jffmpeg.o: in function Java_com_example_swapffmpeg_Jffmpeg_videoinfo:jni/com_example_swapffmpeg_Jffmpeg.c:14: error: undefined reference to 'avcodec_register_all'collect2: ld returned 1 exit status
In this error why it always goes to toolchains? but in android.mk i have provided hardcore path of platform/arch-arm/
Here is my android.mk
LOCAL_PATH:=$(call my-dir)
#declare the prebuilt library
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg-prebuilt
LOCAL_SRC_FILES := ffmpeg/$(TARGET_ARCH_ABI)/libffmpeg.so
LOCAL_EXPORT_C_INCLUDES := ffmpeg/$(TARGET_ARCH_ABI)/include
LOCAL_LDLIBS := -L/Users/swap/android-ndk-r9/platforms/arch-arm/usr/lib - L$(LOCAL_PATH) -lavformat -lavcodec -lavdevice -lavfilter -lavutil -lswscale -lz -ldl -lgcc
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:=com_example_swapffmpeg_Jffmpeg
LOCAL_SRC_FILES:=com_example_swapffmpeg_Jffmpeg.c
LOCAL_SHARED_LIBRARY := ffmpeg-prebuilt
include $(BUILD_SHARED_LIBRARY)