How to Integrate libxml2 native lib in Android-NDK project using CMakeLists.txt and AndroidStudio?

前端 未结 2 1144
终归单人心
终归单人心 2021-01-20 21:57

Please assist me for using libxml2 native-lib - XML parsing library in Android NDK using CMakeLists.txt configura

相关标签:
2条回答
  • 2021-01-20 22:38

    I tried to add xml2 and icuc libraries to Android project. icuc should be added because it is used by xml2 lib. I downloaded libicuc.so and xml2 source code.

    Here I used Android.mk and Application.mk files in jni/ folder:

    # Filename: Application.mk
    APP_ABI=armeabi-v7a
    

    # Filename: Android.mk
    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE := icuuc
    LOCAL_SRC_FILES := libicuuc.so
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/icu/icu4c/source/common
    include $(PREBUILT_SHARED_LIBRARY)
    
    # include $(CLEAR_VARS)
    # LOCAL_MODULE := xml2
    # LOCAL_SRC_FILES := libxml2.so
    # LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/xml
    # LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/xml/include
    # include $(PREBUILT_SHARED_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE    := xml2
    LOCAL_C_INCLUDES := $(LOCAL_PATH)/xml
    LOCAL_C_INCLUDES := $(LOCAL_PATH)/xml/include/
    LOCAL_SRC_FILES :=  xml/SAX.c \
                        xml/entities.c \
                        xml/encoding.c \
                        xml/error.c \
                        xml/parserInternals.c \
                        xml/parser.c \
                        xml/tree.c \
                        xml/hash.c \
                        xml/list.c \
                        xml/xmlIO.c \
                        xml/xmlmemory.c \
                        xml/uri.c \
                        xml/valid.c \
                        xml/xlink.c \
                        xml/debugXML.c \
                        xml/xpath.c \
                        xml/xpointer.c \
                        xml/xinclude.c \
                        xml/nanohttp.c \
                        xml/nanoftp.c \
                        xml/DOCBparser.c \
                        xml/catalog.c \
                        xml/globals.c \
                        #xml/threads.c \
                        xml/c14n.c \
                        xml/xmlstring.c \
                        xml/xmlregexp.c \
                        xml/xmlschemas.c \
                        xml/xmlschemastypes.c \
                        xml/xmlunicode.c \
                        xml/xmlreader.c \
                        xml/relaxng.c \
                        xml/dict.c \
                        xml/SAX2.c \
                        xml/legacy.c \
                        xml/chvalid.c \
                        xml/pattern.c \
                        xml/xmlsave.c \
                        xml/xmlmodule.c \
                        xml/xmlwriter.c \
                        xml/schematron.c
    
    LOCAL_SHARED_LIBRARIES := icuuc
    include $(BUILD_SHARED_LIBRARY)
    

    However, I'm getting clang++ linker error and so many undefined reference error as below. I couldn't find any soulution to fix this issue.

    C:\Users\user\AndroidStudioProjects\SatIP\jni>C:\Users\user\AppData\Local\Android\Sdk\ndk-bundle\ndk-bui
    ld
    Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.
    [armeabi-v7a] Install        : libicuuc.so => libs/armeabi-v7a/libicuuc.so
    [armeabi-v7a] Compile thumb  : xml2 <= SAX.c
    [armeabi-v7a] Compile thumb  : xml2 <= entities.c
    [armeabi-v7a] Compile thumb  : xml2 <= encoding.c
    [armeabi-v7a] Compile thumb  : xml2 <= error.c
    [armeabi-v7a] Compile thumb  : xml2 <= parserInternals.c
    [armeabi-v7a] Compile thumb  : xml2 <= parser.c
    [armeabi-v7a] Compile thumb  : xml2 <= tree.c
    [armeabi-v7a] Compile thumb  : xml2 <= hash.c
    [armeabi-v7a] Compile thumb  : xml2 <= list.c
    [armeabi-v7a] Compile thumb  : xml2 <= xmlIO.c
    [armeabi-v7a] Compile thumb  : xml2 <= xmlmemory.c
    [armeabi-v7a] Compile thumb  : xml2 <= uri.c
    [armeabi-v7a] Compile thumb  : xml2 <= valid.c
    [armeabi-v7a] Compile thumb  : xml2 <= xlink.c
    [armeabi-v7a] Compile thumb  : xml2 <= debugXML.c
    [armeabi-v7a] Compile thumb  : xml2 <= xpath.c
    [armeabi-v7a] Compile thumb  : xml2 <= xpointer.c
    [armeabi-v7a] Compile thumb  : xml2 <= xinclude.c
    [armeabi-v7a] Compile thumb  : xml2 <= nanohttp.c
    [armeabi-v7a] Compile thumb  : xml2 <= nanoftp.c
    [armeabi-v7a] Compile thumb  : xml2 <= DOCBparser.c
    [armeabi-v7a] Compile thumb  : xml2 <= catalog.c
    [armeabi-v7a] Compile thumb  : xml2 <= globals.c
    [armeabi-v7a] SharedLibrary  : libxml2.so
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:268: error: undefined reference to 'xmlStrEqua
    l'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:264: error: undefined reference to 'xmlStrEqua
    l'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:272: error: undefined reference to 'xmlStrEqua
    l'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:278: error: undefined reference to 'xmlStrEqua
    l'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:174: error: undefined reference to 'xmlDictLoo
    kup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:176: error: undefined reference to 'xmlDictLoo
    kup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:178: error: undefined reference to 'xmlDictLoo
    kup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:168: error: undefined reference to 'xmlStrdup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:170: error: undefined reference to 'xmlStrdup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:172: error: undefined reference to 'xmlStrdup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:181: error: undefined reference to 'xmlStrlen'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:184: error: undefined reference to 'xmlDictLoo
    kup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:186: error: undefined reference to 'xmlStrndup
    '
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:705: error: undefined reference to 'xmlStrdup'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:597: error: undefined reference to 'xmlStrstr'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:964: error: undefined reference to 'xmlStrchr'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:111: error: undefined reference to 'xmlDictOwn
    s'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:114: error: undefined reference to 'xmlDictOwn
    s'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:117: error: undefined reference to 'xmlDictOwn
    s'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/entities.c:119: error: undefined reference to 'xmlDictOwn
    s'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:113: error: undefined reference to 'ucnv_open_
    59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:119: error: undefined reference to 'ucnv_setTo
    UCallBack_59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:123: error: undefined reference to 'ucnv_setFr
    omUCallBack_59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:130: error: undefined reference to 'ucnv_open_
    59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:136: error: undefined reference to 'ucnv_close
    _59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:139: error: undefined reference to 'UCNV_TO_U_
    CALLBACK_STOP_59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:139: error: undefined reference to 'UCNV_FROM_
    U_CALLBACK_STOP_59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:145: error: undefined reference to 'ucnv_close
    _59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:146: error: undefined reference to 'ucnv_close
    _59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:1884: error: undefined reference to 'ucnv_conv
    ertEx_59'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2066: error: undefined reference to 'xmlBufUse
    '
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2069: error: undefined reference to 'xmlBufAva
    il'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2086: error: undefined reference to 'xmlBufGro
    w'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2087: error: undefined reference to 'xmlBufAva
    il'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2095: error: undefined reference to 'xmlBufEnd
    '
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2096: error: undefined reference to 'xmlBufCon
    tent'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2097: error: undefined reference to 'xmlBufShr
    ink'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/encoding.c:2098: error: undefined reference to 'xmlBufAdd
    Len'
    ...
    ...
    ...
    ...
    undefined reference to 'xmlSaveForm
    atFileTo'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3109: error: undefined reference to 'xmlRMutexL
    ock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3181: error: undefined reference to 'xmlRMutexU
    nlock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3092: error: undefined reference to 'xmlNewRMut
    ex'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3205: error: undefined reference to 'xmlRMutexL
    ock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3220: error: undefined reference to 'xmlRMutexU
    nlock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3215: error: undefined reference to 'xmlRMutexU
    nlock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3210: error: undefined reference to 'xmlRMutexU
    nlock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3281: error: undefined reference to 'xmlRMutexL
    ock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3295: error: undefined reference to 'xmlFreeRMu
    tex'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:3418: error: undefined reference to 'xmlRMutexL
    ock'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:2235: error: undefined reference to 'xmlIsPubid
    Char_tab'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:2235: error: undefined reference to 'xmlIsPubid
    Char_tab'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/catalog.c:1360: error: undefined reference to 'xmlGetThre
    adId'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Intern
    alSubset'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2IsStan
    dalone'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2HasInt
    ernalSubset'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2HasExt
    ernalSubset'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Resolv
    eEntity'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2GetEnt
    ity'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Entity
    Decl'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Notati
    onDecl'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Attrib
    uteDecl'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Elemen
    tDecl'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Unpars
    edEntityDecl'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2SetDoc
    umentLocator'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2StartD
    ocument'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2EndDoc
    ument'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2StartE
    lement'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2EndEle
    ment'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Refere
    nce'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Charac
    ters'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Charac
    ters'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Proces
    singInstruction'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Commen
    t'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2GetPar
    ameterEntity'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2CDataB
    lock'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXHandler: error: undefined reference to 'xmlSAX2Extern
    alSubset'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXLocator: error: undefined reference to 'xmlSAX2GetPub
    licId'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXLocator: error: undefined reference to 'xmlSAX2GetSys
    temId'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXLocator: error: undefined reference to 'xmlSAX2GetLin
    eNumber'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:xmlDefaultSAXLocator: error: undefined reference to 'xmlSAX2GetCol
    umnNumber'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Inter
    nalSubset'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2IsSta
    ndalone'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2HasIn
    ternalSubset'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2HasEx
    ternalSubset'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Resol
    veEntity'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Entit
    yDecl'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2SetDo
    cumentLocator'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Start
    Document'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2EndDo
    cument'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Start
    Element'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2EndEl
    ement'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Refer
    ence'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Chara
    cters'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Ignor
    ableWhitespace'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2Comme
    nt'
    C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/objs/xml2/xml/globals.o:C:/Users/user/An
    droidStudioProjects/SatIP/jni/xml/globals.c:docbDefaultSAXHandler: error: undefined reference to 'xmlSAX2GetPa
    rameterEntity'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:50: error: undefined reference to 'xmlNewMutex'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:61: error: undefined reference to 'xmlFreeMutex
    '
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:64: error: undefined reference to '__xmlGlobalI
    nitMutexDestroy'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:50: error: undefined reference to 'xmlNewMutex'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:565: error: undefined reference to 'xmlSAX2GetS
    ystemId'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:565: error: undefined reference to 'xmlSAX2GetC
    olumnNumber'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:565: error: undefined reference to 'xmlSAX2GetL
    ineNumber'
    C:/Users/user/AndroidStudioProjects/SatIP/jni/xml/globals.c:565: error: undefined reference to 'xmlSAX2GetP
    ublicId'
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [C:/Users/user/AndroidStudioProjects/SatIP/obj/local/armeabi-v7a/libxml2.so] Error 1
    
    0 讨论(0)
  • 2021-01-20 22:47

    After some search and effort i found some solution. So i would like to answer my own question in following steps :

    1. Clone the source from android/platform_external_libxml2 in your machine.

    2.Add the required all source as well as header files at appropriate place in your project.

    3.With the help of Android.bp file, i managed to configure my app/CMakeList.txt

    4.Configure your app or library level build.gradle file.

    Here is My CMakeLists.txt :

                    cmake_minimum_required(VERSION 3.4.1)
    
                    set(LIBXML2_SOURCES
    
                    src/main/cpp/libxml2/src/SAX.c
                    src/main/cpp/libxml2/src/entities.c
                    src/main/cpp/libxml2/src/encoding.c
                    src/main/cpp/libxml2/src/error.c
                    src/main/cpp/libxml2/src/parserInternals.c
                    src/main/cpp/libxml2/src/parser.c
                    src/main/cpp/libxml2/src/tree.c
                    src/main/cpp/libxml2/src/hash.c
                    src/main/cpp/libxml2/src/list.c
                    src/main/cpp/libxml2/src/xmlIO.c
                    src/main/cpp/libxml2/src/xmlmemory.c
                    src/main/cpp/libxml2/src/uri.c
                    src/main/cpp/libxml2/src/valid.c
                    src/main/cpp/libxml2/src/xlink.c
                    src/main/cpp/libxml2/src/debugXML.c
                    src/main/cpp/libxml2/src/xpath.c
                    src/main/cpp/libxml2/src/xpointer.c
                    src/main/cpp/libxml2/src/xinclude.c
                    src/main/cpp/libxml2/src/DOCBparser.c
                    src/main/cpp/libxml2/src/catalog.c
                    src/main/cpp/libxml2/src/globals.c
                    src/main/cpp/libxml2/src/threads.c
                    src/main/cpp/libxml2/src/c14n.c
                    src/main/cpp/libxml2/src/xmlstring.c
                    src/main/cpp/libxml2/src/buf.c
                    src/main/cpp/libxml2/src/xmlregexp.c
                    src/main/cpp/libxml2/src/xmlschemas.c
                    src/main/cpp/libxml2/src/xmlschemastypes.c
                    src/main/cpp/libxml2/src/xmlunicode.c
                    src/main/cpp/libxml2/src/xmlreader.c
                    src/main/cpp/libxml2/src/relaxng.c
                    src/main/cpp/libxml2/src/dict.c
                    src/main/cpp/libxml2/src/SAX2.c
                    src/main/cpp/libxml2/src/xmlwriter.c
                    src/main/cpp/libxml2/src/legacy.c
                    src/main/cpp/libxml2/src/chvalid.c
                    src/main/cpp/libxml2/src/pattern.c
                    src/main/cpp/libxml2/src/xmlsave.c
                    src/main/cpp/libxml2/src/xmlmodule.c
                    src/main/cpp/libxml2/src/schematron.c
            )
    
            include_directories(src/main/cpp/libxml2/include)
    
            include_directories(src/main/cpp/libxml2/src)
    
            add_library( # Sets the name of the library.
             myexampe-native
    
             # Sets the library as a shared library.
             SHARED
    
             # Provides a relative path to your source file(s).
             src/main/cpp/my-native.cpp )
    
             add_library( # Sets the name of the library.
             mylibxml2
    
             # Sets the library as a shared library.
             SHARED
    
             # Provides a relative path to your source file(s).
             ${LIBXML2_SOURCES} )
    
             target_link_libraries( # Specifies the target library.
    
                       myexampe-native
    
                       mylibxml2
                       )
    

    And Here is my app/build.gradle configuration

                  android { .....
                  defaultConfig { .....
    
                  externalNativeBuild {
            cmake {
                cppFlags "-std=gnu++11"
                arguments '-DANDROID_PLATFORM=android-21',
                          '-DANDROID_STL=c++_shared','-DANDROID_ARM_MODE=arm'
    
            }
        }
    

    Comments are welcomed for any clarification. Thanks :-)

    0 讨论(0)
提交回复
热议问题