我正在尝试从本机C ++代码生成.so文件。这是我的Android.mk文件:
#this directory variable declaration
LOCAL_PATH := $(call my-dir)
FFMPEG_PREBUILT_PATH := $(LOCAL_PATH)/../libs/armeabi/
#mconfnativeshowvideo module START
include $(CLEAR_VARS)
LOCAL_MODULE := mconfnativeshowvideo
LOCAL_SRC_FILES := \
mconfnative/DrawerManager.cpp \
mconfnative/VideoDrawer.cpp
LOCAL_CXXFLAGS := -D__STDC_CONSTANT_MACROS
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/iva/common \
$(LOCAL_PATH)/iva/queue \
$(LOCAL_PATH)/iva/thread \
$(LOCAL_PATH)/ffmpeg
LOCAL_SHARED_LIBRARIES := queue thread common decode
LOCAL_LDLIBS := -lGLESv1_CM -L$(FFMPEG_PREBUILT_PATH) -lavcodec
include $(BUILD_SHARED_LIBRARY)
#mconfnativeshowvideo module END
#mconfnativeencodevideo module START
include $(CLEAR_VARS)
LOCAL_MODULE := mconfnativeencodevideo
LOCAL_SRC_FILES := \
mconfnative/EncoderManager.cpp \
mconfnative/VideoEncoder.cpp \
mconfnative/ImageRotator.cpp
LOCAL_CXXFLAGS := -D__STDC_CONSTANT_MACROS
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/iva/common \
$(LOCAL_PATH)/iva/queue \
$(LOCAL_PATH)/iva/thread \
$(LOCAL_PATH)/ffmpeg
LOCAL_SHARED_LIBRARIES := queue thread common encode
include $(BUILD_SHARED_LIBRARY)
#mconfnativeencodevideo module END
#thread module
include $(CLEAR_VARS)
LOCAL_MODULE := thread
LOCAL_CFLAGS := -std=gnu++0x
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/iva/common
LOCAL_CPPFLAGS += -fexceptions
LOCAL_SRC_FILES := \
iva/thread/ConditionVariable.cpp \
iva/thread/Interval.cpp \
iva/thread/Interval_linux.cpp \
iva/thread/Microseconds.cpp \
iva/thread/Milliseconds.cpp \
iva/thread/Mutex.cpp \
iva/thread/Seconds.cpp \
iva/thread/Thread.cpp \
iva/thread/Timer.cpp
include $(BUILD_SHARED_LIBRARY)
#end of thread module
#common module
include $(CLEAR_VARS)
LOCAL_MODULE := common
LOCAL_SHARED_LIBRARIES := thread
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/iva/thread \
$(LOCAL_PATH)/iva/common \
$(LOCAL_PATH)/ffmpeg
LOCAL_LDLIBS += -llog -L$(FFMPEG_PREBUILT_PATH) -lavcodec -lavutil
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS
LOCAL_CPPFLAGS += -fexceptions
LOCAL_SRC_FILES := \
iva/common/AVConfigs.cpp \
iva/common/CommonColor.cpp \
iva/common/CommonRect.cpp \
iva/common/Directory.cpp \
iva/common/Directory_linux.cpp \
iva/common/ErrorController.cpp \
iva/common/ErrorData.cpp \
iva/common/ErrorStack.cpp \
iva/common/ErrorVector.cpp \
iva/common/Folders.cpp \
iva/common/IPV4.cpp \
iva/common/IvaOutBuffer.cpp \
iva/common/IvaOutController.cpp \
iva/common/IvaOutLogFile.cpp \
iva/common/IvaOutStream.cpp \
iva/common/IvaPixFmt.cpp \
iva/common/IvaPixFmt_linux.cpp \
iva/common/IvaString.cpp \
iva/common/IvaTime.cpp \
iva/common/IvaVideoFrame.cpp \
iva/common/Location.cpp \
iva/common/LogData.cpp \
iva/common/SysInfo_linux.cpp
include $(BUILD_SHARED_LIBRARY)
#end of common module
#queue module
include $(CLEAR_VARS)
LOCAL_MODULE := queue
LOCAL_SHARED_LIBRARIES := thread common
LOCAL_C_INCLUDES := $(LOCAL_PATH)/iva/thread \
$(LOCAL_PATH)/iva/common \
$(LOCAL_PATH)/ffmpeg
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS
LOCAL_SRC_FILES := iva/queue/queue.cpp \
iva/queue/QueueBuffer.cpp \
iva/queue/QueueDiscard.cpp \
iva/queue/QueueDiscardPolicy.cpp \
iva/queue/QueueExtraData.cpp \
iva/queue/QueueExtraDataAudio.cpp \
iva/queue/QueueExtraDataVideo.cpp
include $(BUILD_SHARED_LIBRARY)
#end of queue module
#decode module
include $(CLEAR_VARS)
LOCAL_MODULE := decode
LOCAL_SHARED_LIBRARIES := thread common queue
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/iva/thread \
$(LOCAL_PATH)/iva/common \
$(LOCAL_PATH)/iva/queue \
$(LOCAL_PATH)/iva/decode \
$(LOCAL_PATH)/ffmpeg
LOCAL_LDLIBS += -L$(FFMPEG_PREBUILT_PATH) -lavcodec -lavutil -lswscale
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS
LOCAL_SRC_FILES := iva/decode/Decode.cpp \
iva/decode/DecodeAudio.cpp \
iva/decode/DecodeVideo.cpp
include $(BUILD_SHARED_LIBRARY)
#end of decode module
#encode module
include $(CLEAR_VARS)
LOCAL_MODULE := encode
LOCAL_SHARED_LIBRARIES := thread common queue
LOCAL_LDLIBS += -L$(FFMPEG_PREBUILT_PATH) -lavcodec -lavutil -lswscale -lavformat
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/iva/thread \
$(LOCAL_PATH)/iva/common \
$(LOCAL_PATH)/iva/queue \
$(LOCAL_PATH)/iva/encode \
$(LOCAL_PATH)/ffmpeg
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS
LOCAL_SRC_FILES := iva/encode/Encode.cpp \
iva/encode/EncodeAudio.cpp \
iva/encode/EncodeAudioParams.cpp \
iva/encode/EncodeVideo.cpp \
iva/encode/EncodeVideoParams.cpp \
iva/encode/VideoLoader.cpp
include $(BUILD_SHARED_LIBRARY)
#end of encode module
当我尝试使用Android NDK构建项目时,它会出现以下错误
/home/iamharsh/adt-bundle-linux-x86_64-20130717/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lavcodec
/home/iamharsh/adt-bundle-linux-x86_64-20130717/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lavutil
/home/iamharsh/adt-bundle-linux-x86_64-20130717/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/common/iva/common/IvaVideoFrame.o: in function IvaVideoFrame::freeInternalData():jni/iva/common/IvaVideoFrame.cpp:19: error: undefined reference to 'avpicture_free'
/home/iamharsh/adt-bundle-linux-x86_64-20130717/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/common/iva/common/IvaVideoFrame.o: in function IvaVideoFrame::freeInternalData():jni/iva/common/IvaVideoFrame.cpp:20: error: undefined reference to 'av_free'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libcommon.so] Error 1
函数av_free和avpicture_free存在于不同目录中的不同头文件中。因此,我尝试使用相对路径导入它们,但仍然没有好处。任何帮助或建议都会非常感激。