[Libav-user] Error when creating .so file using .c program and ffmpeg using android NDK

prathap prathap.malempati at gmail.com
Fri May 31 08:39:09 CEST 2013


Thanks for your previous solution , and  now i  have two Android.mk files
in my project

1    .../(my_project_root)/jni/Android.mk

2    .../ (my_project_root)/jni/ffmpeg/android/arm/Android.mk


and my first android.mk code is:

-----------------------------------------------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := framegrabber
LOCAL_SRC_FILES := framegrabber.c
LOCAL_LDLIBS := -llog -lz
LOCAL_STATIC_LIBRARIES := libavformat_static libavcodec_static
libavutil_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg/android/arm)
-------------------------------------------------------------------------------

and my second android.mk code is:

-----------------------------------------------------------------------------
LOCAL_PATH:= $(call my-dir)
#static version of libavcodec
include $(CLEAR_VARS)
LOCAL_MODULE:= libavcodec_static
LOCAL_SRC_FILES:= lib/libavcodec.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
#static version of libavformat
include $(CLEAR_VARS)
LOCAL_MODULE:= libavformat_static
LOCAL_SRC_FILES:= lib/libavformat.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
#static version of libswscale
include $(CLEAR_VARS)
LOCAL_MODULE:= libswscale_static
LOCAL_SRC_FILES:= lib/libswscale.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
#static version of libavutil
include $(CLEAR_VARS)
LOCAL_MODULE:= libavutil_static
LOCAL_SRC_FILES:= lib/libavutil.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
----------------------------------------------------------------------------------------------------------


when i am trying to run ndk-build it shows Error like this:

--------------------------------------------------------------------------------------------------
Android NDK: /home/ubuntu/workspace/MyFfmpegTest/jni/Android.mk: Cannot
find module with tag 'ffmpeg/android/arm' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined
?
Android NDK: The following directories were searched:
Android NDK:
/home/ubuntu/workspace/MyFfmpegTest/jni/Android.mk:8: *** Android NDK:
Aborting.    .  Stop.
------------------------------------------------------------------------------------------------------

Could you please tell me where the mistake is?

Thank you

Regards
Prathap.M


On Fri, May 31, 2013 at 11:43 AM, Prathap Malempati <
prathap.malempati at gmail.com> wrote:

> Ok, thhank you..........
>
>
> On Fri, May 31, 2013 at 11:15 AM, Alex Cohn [via libav-users] <
> ml-node+s943685n4657774h40 at n4.nabble.com> wrote:
>
>> On May 30, 2013 9:36 PM, "prathap" <[hidden email]<http://user/SendEmail.jtp?type=node&node=4657774&i=0>>
>> wrote:
>> >
>> > Hi everybody
>> >
>> > when i am trying to create .so file using .c file and ffmpeg and
>> android NDK
>> > i got this errors
>> >
>> >
>> > Install        : libmylib.so => libs/armeabi-v7a/libmylib.so
>> > Install        : libmylib.so => libs/armeabi/libmylib.so
>> > Compile x86    : mylib <= mylib.c
>> > cc1: error: unrecognized command line option '-mfloat-abi=softfp'
>> > cc1: error: unrecognized command line option '-mfpu=neon'
>> > jni/mylib.c:1:0: error: bad value (armv7-a) for -march= switch
>> > make: *** [obj/local/x86/objs/mylib/mylib.o] Error 1
>> >
>> >
>> ----------------------------------------------------------------------------------------------------------------------
>> >
>> >
>> > My android.mk file is
>> >
>> > LOCAL_PATH := $(call my-dir)
>> >
>> > include $(CLEAR_VARS)
>> >
>> > LOCAL_LDLIBS =
>> -L$(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm/usr/lib
>> > -L$(LOCAL_PATH)/../obj/local/armeabi/ -lavformat -lavcodec -lpostproc
>> > -lswscale -lavutil -llog -ljnigraphics -lz -ldl -lgcc
>> > LOCAL_C_INCLUDES += $(LOCAL_PATH)/ffmpeg
>> > LOCAL_SRC_FILES := mylib.c
>> > LOCAL_CFLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon
>> > LOCAL_MODULE := mylib
>> > #LOCAL_SRC_FILES := mylib.c
>> >
>> > include $(BUILD_SHARED_LIBRARY)
>> >
>> > LOCAL_PATH := $(call my-dir)
>> > LOCAL_C_INCLUDES += $(LOCAL_PATH)/ffmpeg
>> > include $(all-subdir-makefiles)
>> >
>> >
>> -----------------------------------------------------------------------------------------------------------------------
>> >
>> >
>> > My .c program is like this
>> >
>> >
>> > #include <jni.h>
>> > #include <android/log.h>
>> > #include <com_myffmpegtest_MainActivity.h>
>> >
>> > #include <libavcodec/avcodec.h>
>> > #include <libavformat/avformat.h>
>> > #include <libavformat/avio.h>
>> > #include <libswscale/swscale.h>
>> > #include <libavutil/avstring.h>
>> >
>> > #define LOG_TAG "mylib"
>> > #define LOGI(...)  __android_log_print(ANDROID_LOG_INFO, LOG_TAG,
>> > __VA_ARGS__)
>> > #define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
>> > __VA_ARGS__)
>> >
>> > JNIEXPORT jint JNICALL Java_com_myffmpegtest_MainActivity_logFileInfo
>> > (JNIEnv *env, jclass this, jstring filename)
>> > {
>> >     av_register_all();
>> >
>> >     AVFormatContext *pFormatCtx;
>> >     const jbyte *str;
>> >     str = (*env)->GetStringUTFChars(env, filename, NULL);
>> >
>> >     if(avformat_open_input(&pFormatCtx, str, NULL, NULL)!=0)
>> >     {
>> >         LOGE("Can't open file '%s'\n", str);
>> >         return 1;
>> >     }
>> >     else
>> >     {
>> >         LOGI("File was opened\n");
>> >         LOGI("File '%s', Codec %s",
>> >            pFormatCtx->filename,
>> >             pFormatCtx->iformat->name
>> >         );
>> >     }
>> >     return 0;
>> > }
>> >
>> >
>> -------------------------------------------------------------------------------------------------------------------
>> >
>> >
>> > Thanks for you suggestions
>> >
>> > Regards
>> > Prathap.M
>>
>> You set compiler options for ARM processor. In your ndk-build command,
>> add APP_ABI=armeabi-v7a. If you really need x86 version, specify the
>> relevant compilation options separately.
>>
>> BR,
>> Alex Cohn
>>
>> _______________________________________________
>> Libav-user mailing list
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=4657774&i=1>
>> http://ffmpeg.org/mailman/listinfo/libav-user
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://libav-users.943685.n4.nabble.com/Error-when-creating-so-file-using-c-program-and-ffmpeg-using-android-NDK-tp4657764p4657774.html
>>  To unsubscribe from Error when creating .so file using .c program and
>> ffmpeg using android NDK, click here<http://libav-users.943685.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4657764&code=cHJhdGhhcC5tYWxlbXBhdGlAZ21haWwuY29tfDQ2NTc3NjR8LTEyNDg5ODE1ODM=>
>> .
>> NAML<http://libav-users.943685.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>




--
View this message in context: http://libav-users.943685.n4.nabble.com/Error-when-creating-so-file-using-c-program-and-ffmpeg-using-android-NDK-tp4657764p4657776.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list