在eclipse下android ndk直接编译librtmp。

时间:2021-06-01 00:16:22

需要openssl的libcrypto.a,libssl.a

jni目录下

文件夹librtmp

文件夹openssl

文件Android.mk

Android.mk中

LOCAL_PATH:= $(call my-dir)
include $(LOCAL_PATH)/openssl/Android.mk
include $(LOCAL_PATH)/librtmp/Android.mk

openssl目录下

include,libcrypto.a,libssl.a,Android.mk

Android.mk中

include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
libcrypto.a \

LOCAL_MODULE := crypto
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)


include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
libssl.a \

LOCAL_MODULE := ssl
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)

librtmp目录下

文件夹librtmp

文件Android.mk

Android.mk中

subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
librtmp \
))

SSL := $(LOCAL_PATH)/openssl
ifndef SSL
$(error "You must define SSL before starting")
endif

include $(LOCAL_PATH)/librtmp/librtmp/Android.mk
librtmp下就是源码和Android.mk

Android.mk中

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_C_INCLUDES += $(NDK_PROJECT_PATH)/librtmp \
$(SSL)/include
LOCAL_SRC_FILES:= \
amf.c \
hashswf.c \
log.c \
parseurl.c \
rtmp.c
LOCAL_SHARED_LIBRARIES := crypto
LOCAL_SHARED_LIBRARIES += ssl
#LOCAL_CFLAGS += -I$(SSL)/include -DUSE_OPENSSL
LOCAL_LDLIBS += -L$(SSL)
LOCAL_LDLIBS += -lssl -lcrypto -lz
LOCAL_MODULE := librtmp

include $(BUILD_SHARED_LIBRARY)


右键运行,就可以编译通过