I want to make an Android application using huge third party native libraries whi开发者_C百科ch use the Gnu build tools (gnu makefile).
My question is how to write the "Android.mk" files for these libraries in order to build them using the Android build system or the Android NDK.
Thanks in advance
As far as i understand, you need to convert the makefiles to android format :( and use ndk_buidl to build them
The only feasible way will be to write the NDK makefiles. Many big libraries has been ported that way. Normally you should run the configure
script to generate the config.h and config.mak files. You'll use the config.mak to list your sources. There are tutorials over the net for porting some popular libraries to be built with Android's NDK. I had success with freetype, ffmpeg, SDL, DevIL and more.
You can use following trick: download agcc, then compile your library with
./configure CC=agcc CXX=agcc --host=arm-linux-androideabi && make
. After that create simple jni/Android.mk
like this:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := jni.cpp # this file will provide native methods for java part
LOCAL_LDLIBS += libYourLibraryBuiltWithGNUToolchain.a
LOCAL_MODULE := YourSoLibrary
include $(BUILD_SHARED_LIBRARY)
After that you can build your so library with ndk-build script.
More recent releases of the ndk allow you to generate a stand-alone toolchain which encapsulates most of the android uniqueness so that it can be invoked more like a normal gcc and support programs. This is somewhat suitable for use with existing project build systems - though configure scripts which assume the ability to execute target feature test code on the host will fail, just as they do in any cross compilation case.
精彩评论