Please assist me for using libxml2
native-lib - XML parsing library in Android NDK using CMakeLists.txt
configura
After some search and effort i found some solution. So i would like to answer my own question in following steps :
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 :-)