android - error: undefined reference to 'av_free_packet(AVPacket*)' when use NDK to compile ffmpeg -


i compiled cpps use ffmpeg liberary android ndk android mk follow :

    local_path := $(call my-dir)     defines += -dtarget_posix \                -dtarget_linux \            -d_linux \            -dtarget_android \            -d__stdc_constant_macros       include $(clear_vars)       local_module := libavcodec     local_src_files := lib/lib/libavcodec.so      include $(prebuilt_shared_library)        include $(clear_vars)       local_module := libavfilter       local_src_files := lib/lib/libavfilter.so      include $(prebuilt_shared_library)        include $(clear_vars)       local_module := libavformat       local_src_files := lib/lib/libavformat.so       include $(prebuilt_shared_library)        include $(clear_vars)       local_module := libavutil       local_src_files := lib/lib/libavutil.so       include $(prebuilt_shared_library)        include $(clear_vars)       local_module := libpostproc       local_src_files := lib/lib/libpostproc.so        include $(prebuilt_shared_library)        include $(clear_vars)       local_module := libswresample       local_src_files := lib/lib/libswresample.so        include $(prebuilt_shared_library)        include $(clear_vars)       local_module := libswscale       local_src_files := lib/lib/libswscale.so     include $(prebuilt_shared_library)        include $(clear_vars)     local_module:= player     base := $(local_path)     local_src_files += cores/playdemux.cpp \                    cores/playdemuxffmpeg.cpp \                    cores/playfactorydemuxer.cpp      local_c_includes += $(local_path) \             $(local_path)/lib \             $(local_path)/lib/include \             $(local_path)/cores/player \     local_cppflags += -wall -fexceptions $(defines)     include $(build_static_library)      include $(clear_vars)     local_module:= testmain      local_src_files := \         testmain.cpp \      local_c_includes += $(local_path) \                 $(local_path)/lib      local_cppflags += -wall -fexceptions $(defines)      local_shared_libraries := libavcodec \                 libavformat \                 libavfilter \                 libavutil \                 libpostproc \                 libswscale \                 libswresample       local_static_libraries := player       include $(build_executable) 

but when "ndk-build v=1", after compiling, got :

    install        : libavcodec.so => libs/armeabi-v7a/libavcodec.so     install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavcodec.so /cygdrive/d/player/libs/armeabi-v7a/libavcodec.so     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded d:/player/libs/armeabi-v7a/libavcodec.so     install        : libavfilter.so => libs/armeabi-v7a/libavfilter.so     install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavfilter.so /cygdrive/d/player/libs/armeabi-v7a/libavfilter.so     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded d:/player/libs/armeabi-v7a/libavfilter.so     install        : libavformat.so => libs/armeabi-v7a/libavformat.so     install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavformat.so /cygdrive/d/player/libs/armeabi-v7a/libavformat.so     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded d:/player/libs/armeabi-v7a/libavformat.so     install        : libavutil.so => libs/armeabi-v7a/libavutil.so     install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavutil.so /cygdrive/d/player/libs/armeabi-v7a/libavutil.so     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded d:/player/libs/armeabi-v7a/libavutil.so     install        : libpostproc.so => libs/armeabi-v7a/libpostproc.so     install -p /cygdrive/d/player/obj/local/armeabi-v7a/libpostproc.so /cygdrive/d/player/libs/armeabi-v7a/libpostproc.so     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded d:/player/libs/armeabi-v7a/libpostproc.so     install        : libswresample.so => libs/armeabi-v7a/libswresample.so     install -p /cygdrive/d/player/obj/local/armeabi-v7a/libswresample.so /cygdrive/d/player/libs/armeabi-v7a/libswresample.so     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded d:/player/libs/armeabi-v7a/libswresample.so     install        : libswscale.so => libs/armeabi-v7a/libswscale.so     install -p /cygdrive/d/player/obj/local/armeabi-v7a/libswscale.so /cygdrive/d/player/libs/armeabi-v7a/libswscale.so     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded d:/player/libs/armeabi-v7a/libswscale.so     executable     : testmain     /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-g++  -wl,--gc-sections  -wl,-z,nocopyreloc  --sysroot=d:/android/android-ndk-r8e/platforms/android-14/arch-arm  d:/player/obj/local/armeabi-v7a/objs/testmain/testmain.o d:/player/obj/local/armeabi-v7a/libplayer.a d:/android/android-ndk-r8e/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a -lgcc d:/player/obj/local/armeabi-v7a/libavcodec.so d:/player/obj/local/armeabi-v7a/libavformat.so d:/player/obj/local/armeabi-v7a/libavfilter.so d:/player/obj/local/armeabi-v7a/libavutil.so d:/player/obj/local/armeabi-v7a/libpostproc.so d:/player/obj/local/armeabi-v7a/libswscale.so d:/player/obj/local/armeabi-v7a/libswresample.so  -no-canonical-prefixes -march=armv7-a  -wl,--fix-cortex-a8  -wl,--no-undefined -wl,-z,noexecstack -wl,-z,relro -wl,-z,now    -lc -lm  -o d:/player/obj/local/armeabi-v7a/testmain     d:/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: d:/player/obj/local/armeabi-v7a/libplayer.a(playdemuxffmpeg.o): in function playdemuxffmpeg::flush():d:/player/jni/lib/dllavcodec.h:144: error: undefined reference 'av_free_packet(avpacket*)' 

i´m using windows 7 + cygwin + ndkr8,but lib "libavcodec.so ,libavfilter.so,libavformat.so,libavutil.so,libpostproc.so,libswresample.so,libswscale.so " of ffmpeg compiled standalone mothed of ndk using "ubuntu + ndk8". , include extern "c" code in head file.

so, how correct error ?

my dllavcodec.h :

#pragma once #include "dllavutil.h"  extern "c" {   #include <libavcodec/avcodec.h> }   class dllavcodec : public dllavcodecinterface { public:   static ccriticalsection m_critsection;    virtual ~dllavcodec() {}   virtual void avcodec_register_all()   {     ::avcodec_register_all();   }   virtual void avcodec_flush_buffers(avcodeccontext *avctx) { ::avcodec_flush_buffers(avctx); }   virtual int avcodec_open2(avcodeccontext *avctx, avcodec *codec, avdictionary **options)   {     return ::avcodec_open2(avctx, codec, options);   }   virtual int avcodec_open2_dont_call(avcodeccontext *avctx, avcodec *codec, avdictionary **options) { *(volatile int *)0x0 = 0; return 0; }   virtual int avcodec_close_dont_call(avcodeccontext *avctx) { *(volatile int *)0x0 = 0; return 0; }   virtual avcodec *avcodec_find_decoder(enum codecid id) { return ::avcodec_find_decoder(id); }   virtual avcodec *avcodec_find_encoder(enum codecid id) { return ::avcodec_find_encoder(id); }   virtual int avcodec_close(avcodeccontext *avctx)   {     return ::avcodec_close(avctx);   }   virtual avframe *avcodec_alloc_frame() { return ::avcodec_alloc_frame(); }   virtual int avpicture_fill(avpicture *picture, uint8_t *ptr, pixelformat pix_fmt, int width, int height) { return ::avpicture_fill(picture, ptr, pix_fmt, width, height); }   virtual int avcodec_decode_video2(avcodeccontext *avctx, avframe *picture, int *got_picture_ptr, avpacket *avpkt) { return ::avcodec_decode_video2(avctx, picture, got_picture_ptr, avpkt); }   virtual int avcodec_decode_audio4(avcodeccontext *avctx, avframe *frame, int *got_frame_ptr, avpacket *avpkt) { return ::avcodec_decode_audio4(avctx, frame, got_frame_ptr, avpkt); }   virtual int avcodec_decode_subtitle2(avcodeccontext *avctx, avsubtitle *sub, int *got_sub_ptr, avpacket *avpkt) { return ::avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, avpkt); }   virtual int avcodec_encode_audio(avcodeccontext *avctx, uint8_t *buf, int buf_size, const short *samples) { return ::avcodec_encode_audio(avctx, buf, buf_size, samples); }   virtual int avcodec_encode_audio2(avcodeccontext *avctx, avpacket *avpkt, const avframe *frame, int *got_packet_ptr) { return ::avcodec_encode_audio2(avctx, avpkt, frame, got_packet_ptr); }   virtual int avpicture_get_size(pixelformat pix_fmt, int width, int height) { return ::avpicture_get_size(pix_fmt, width, height); }   virtual avcodeccontext *avcodec_alloc_context3(avcodec *codec) { return ::avcodec_alloc_context3(codec); }   virtual void avcodec_string(char *buf, int buf_size, avcodeccontext *enc, int encode) { ::avcodec_string(buf, buf_size, enc, encode); }   virtual void avcodec_get_context_defaults3(avcodeccontext *s, avcodec *codec) { ::avcodec_get_context_defaults3(s, codec); }    virtual avcodecparsercontext *av_parser_init(int codec_id) { return ::av_parser_init(codec_id); }   virtual int av_parser_parse2(avcodecparsercontext *s,avcodeccontext *avctx, uint8_t **poutbuf, int *poutbuf_size,                     const uint8_t *buf, int buf_size,                     int64_t pts, int64_t dts, int64_t pos)   {     return ::av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, pos);   }   virtual void av_parser_close(avcodecparsercontext *s) { ::av_parser_close(s); }    virtual avbitstreamfiltercontext *av_bitstream_filter_init(const char *name) { return ::av_bitstream_filter_init(name); }   virtual int av_bitstream_filter_filter(avbitstreamfiltercontext *bsfc,     avcodeccontext *avctx, const char *args,     uint8_t **poutbuf, int *poutbuf_size,     const uint8_t *buf, int buf_size, int keyframe) { return ::av_bitstream_filter_filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe); }   virtual void av_bitstream_filter_close(avbitstreamfiltercontext *bsfc) { ::av_bitstream_filter_close(bsfc); }    virtual void avpicture_free(avpicture *picture) { ::avpicture_free(picture); }   virtual void av_free_packet(avpacket *pkt) { ::av_free_packet(pkt); }   virtual int avpicture_alloc(avpicture *picture, pixelformat pix_fmt, int width, int height) { return ::avpicture_alloc(picture, pix_fmt, width, height); }   virtual int avcodec_default_get_buffer(avcodeccontext *s, avframe *pic) { return ::avcodec_default_get_buffer(s, pic); }   virtual void avcodec_default_release_buffer(avcodeccontext *s, avframe *pic) { ::avcodec_default_release_buffer(s, pic); }   virtual enum pixelformat avcodec_default_get_format(struct avcodeccontext *s, const enum pixelformat *fmt) { return ::avcodec_default_get_format(s, fmt); }   virtual avcodec *av_codec_next(avcodec *c) { return ::av_codec_next(c); }    virtual int av_dup_packet(avpacket *pkt) { return ::av_dup_packet(pkt); }   virtual void av_init_packet(avpacket *pkt) { return ::av_init_packet(pkt); }   virtual int avcodec_fill_audio_frame(avframe *frame, int nb_channels, enum avsampleformat sample_fmt, const uint8_t *buf, int buf_size, int align) { return ::avcodec_fill_audio_frame(frame, nb_channels, sample_fmt, buf, buf_size, align); }   virtual void avcodec_free_frame(avframe **frame) { return ::avcodec_free_frame(frame); }; }; 

i have made small experiment. believe problem still extern "c". posted dllavcodec.h file, afraid in playdemuxffmpeg.cpp #include ffmpeg headers without extern "c" wrapper (maybe not in cpp file, in 1 of headers includes before dllavcodec.h).


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -