gloox移植到android平台

最近需要在android平台是使用gloox,官方gloox没有没有对应的Android.mk文件,那当然也可以用android ndk来编译,但是我觉得用ndk编译有点麻烦,就写一个Android.mk来使用mm编译。

首先,进入src目录,configure该项目:

./configure --host=arm-linux CC=arm-none-eabi-gcc

然后,打开Makefile.in,并拷贝出libgloox_la_SOURCES所有的内容,并保存在Makefile.inc文件中

libgloox_la_SOURCES = ip.cpp jid.cpp parser.cpp connectiontcpclient.cpp clientbase.cpp tag.cpp stanza.cpp logsink.cpp \
                        dns.cpp prep.cpp base64.cpp client.cpp component.cpp \
                        disco.cpp adhoc.cpp privatexml.cpp registration.cpp \
                        nonsaslauth.cpp rosteritem.cpp rostermanager.cpp privacyitem.cpp \
                        bookmarkstorage.cpp annotations.cpp privacymanager.cpp lastactivity.cpp \
                        flexoff.cpp dataform.cpp dataformfield.cpp dataformfieldcontainer.cpp \
                        messagesession.cpp messageeventfilter.cpp chatstatefilter.cpp gloox.cpp \
                        inbandbytestream.cpp messagefilter.cpp vcard.cpp \
                        vcardmanager.cpp md5.cpp sha.cpp search.cpp dataformreported.cpp dataformitem.cpp \
                        mucroom.cpp mucmessagesession.cpp oob.cpp vcardupdate.cpp stanzaextensionfactory.cpp \
                        delayeddelivery.cpp gpgencrypted.cpp gpgsigned.cpp \
                        uniquemucroom.cpp instantmucroom.cpp compressionzlib.cpp tlsgnutlsclient.cpp \
                        connectionhttpproxy.cpp tlsgnutlsserveranon.cpp tlsgnutlsbase.cpp \
                        tlsgnutlsclientanon.cpp tlsschannel.cpp tlsdefault.cpp simanager.cpp siprofileft.cpp \
                        mutex.cpp connectionsocks5proxy.cpp socks5bytestreammanager.cpp socks5bytestream.cpp \
                        connectiontcpbase.cpp connectiontcpserver.cpp socks5bytestreamserver.cpp amp.cpp \
                        pubsubitem.cpp pubsubmanager.cpp \
                        error.cpp util.cpp iq.cpp message.cpp presence.cpp \
                        subscription.cpp capabilities.cpp chatstate.cpp connectionbosh.cpp connectiontls.cpp \
                        messageevent.cpp receipt.cpp nickname.cpp eventdispatcher.cpp \
                        pubsubevent.cpp xhtmlim.cpp featureneg.cpp \
                        shim.cpp softwareversion.cpp attention.cpp \
                        tlsopensslclient.cpp tlsopensslbase.cpp \
                        tlsopensslserver.cpp compressiondefault.cpp \
                        connectiontlsserver.cpp


接着,编写Android.mk文件

LOCAL_PATH:= $(call my-dir)
 
include $(CLEAR_VARS)
include $(LOCAL_PATH)/Makefile.inc
 
local_src_files := $(addprefix ./,$(libgloox_la_SOURCES))
#LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ $(LOCAL_PATH)/../zlib
 
local_c_includes := \
    $(LOCAL_PATH)/.. \
    external/stlport/stlport \
    external/zlib \
    external/openssl/include \
    bionic
#######################################
# target shared library
 
#######################################
# target lib
 
LOCAL_SRC_FILES  := $(local_src_files)
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_SHARED_LIBRARIES := libz libssl libcrypto libstlport
 
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE:= libgloox
LOCAL_MODULE_TAGS := optional
 
include $(BUILD_SHARED_LIBRARY)
 
#######################################
# target static library
 
#######################################
#static library
 
include $(CLEAR_VARS)
LOCAL_SRC_FILES  := $(local_src_files)
LOCAL_C_INCLUDES += $(local_c_includes)
 
LOCAL_LDLIBS := -lz -lssl -crypto
LOCAL_MODULE    := libgloox
include $(BUILD_STATIC_LIBRARY)

最后,执行mm并得到libgloox.so和libgloox.a.

你可能感兴趣的:(gloox移植到android平台)