1

如何使用 Android-NDK R8 使用给定的共享库构建可执行 bin?我试图通过创建一个给定共享库的 PREBUILT_SHARED_LIBRARY 来创建一个 bin,但总是出现“错误:未定义对 'av_free_packet(AVPacket*)' 的引用”。

我的 android.mk 是:

LOCAL_PATH := $(call my-dir)
DEFINES += \
           -DTARGET_POSIX \
           -DTARGET_LINUX \
           -D_LINUX \
           -DTARGET_ANDROID \
           -D__STDC_CONSTANT_MACROS 

######################################
#build ffmpeg prebuilt lib
######################################
include $(CLEAR_VARS)  
LOCAL_MODULE := libavcodec
LOCAL_SRC_FILES := lib/lib/libavcodec.a 
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)  
LOCAL_MODULE := libavfilter  
LOCAL_SRC_FILES := lib/lib/libavfilter.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)  
LOCAL_MODULE := libavformat  
LOCAL_SRC_FILES := lib/lib/libavformat.a  
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)  
LOCAL_MODULE := libavutil  
LOCAL_SRC_FILES := lib/lib/libavutil.a  
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)  
LOCAL_MODULE := libpostproc  
LOCAL_SRC_FILES := lib/lib/libpostproc.a   
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)  
LOCAL_MODULE := libswresample  
LOCAL_SRC_FILES := lib/lib/libswresample.a   
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)  
LOCAL_MODULE := libswscale  
LOCAL_SRC_FILES := lib/lib/libswscale.a
LOCAL_EXPORT_C_INCLUDES +=$(LOCAL_PATH)/lib/include
include $(PREBUILT_STATIC_LIBRARY)


######################################
#build thread lib
######################################
include $(CLEAR_VARS)
LOCAL_MODULE:= player
base := $(LOCAL_PATH)

LOCAL_SRC_FILES += ......

LOCAL_CPPFLAGS += -Wall -fexceptions $(DEFINES)  
LOCAL_LDLIBS += -llog -lz
LOCAL_LDFLAGS += -L../jni/lib/lib  -lavcodec -lavformat  -lavutil -lavfilter -lpostproc  -lswscale -lswresample

LOCAL_STATIC_LIBRARIES := libavcodec \
                          libavformat \
                          libavutil \
                          libavfilter \
                          libpostproc \
                          libswscale \
                          libswresample 

include $(BUILD_SHARED_LIBRARY)
4

0 回答 0