5

We have an application working fine for Mac and Windows platform, now targeting for Android and iOS, Application using libxml for parsing of XML data, and my question is ?

1 -- Do i need to build libxml for Android platform or its already there as a part of NDK ?

if need to build any pointers how to start ?

2
  • It's not a part of NDK. For pointers how to start - start with the NDK readme, move on to Java's JNI docs. Commented Aug 21, 2012 at 14:27
  • thanks for your comment, actually i am aware of NDK Environment, what i want to know is, Having OSX Platform, how to compile libxml for Android, some cross compilation process to compile libxml for Android platform. Commented Aug 22, 2012 at 6:31

1 Answer 1

12

You have two options:

Write an Android.mk that can successfully build libxml, and depend on the result of that in your main Android.mk. You can try to build libxml natively (using the configure script and make) on your Mac to get an idea of what files need to be built, and if any special flags need to be passed.

Or, Use libxml's configure script and build libxml for Android using the NDK's toolchain. You'll have to do something like this:

NDK_ROOT=/path/to/ndk API_LEVEL=YOUR_API_LEVEL SYSROOT=$NDK_ROOT/platforms/android-$API_LEVEL/arch-arm export CC="$NDK_ROOT/toolchains/arm-linux-androideabi-4.4.3/Darwin-x86/bin/arm-linux-androideabi-gcc" export CFLAGS="--sysroot=$SYSROOT" export LDFLAGS="--sysroot=$SYSROOT" ./configure --host=arm-linux-gnueabi --enable-static --disable-shared make libxml2.la 

Technically the host triplet for Android is arm-linux-androideabi, but most configure scripts don't recognize it, and for our purposes here, -gnueabi is close enough.

I ended up suggesting make libxml2.la rather than just make because the tests weren't building properly. The resulting library will end up in the .libs/ folder.

The second method might be a little easier, but if you intend to build your app for multiple architectures (arm, armv7-a, maybe even x86 and mips), writing your own Android.mk will save you time in the long run.

Sign up to request clarification or add additional context in comments.

3 Comments

@keinos : Thanks i will try and let you know
Hey, the tests aren't building because of the missing glob files. Just have a look at this thread groups.google.com/forum/#!topic/android-ndk/vSH6MWPD0Vk
It's not clear enough for me... libxml2 is "the standard" for Android? Or there are another "Java world" XML parser... Or, by default, no XML parser at commom Android?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.