How to write Android.mk for a library using Gnu makefile

I want to make an Android application using huge third-party libraries that use the Gnu build tools (gnu makefile).

My question is how to write Android.mk files for these libraries in order to create them using the Android build system or Android NDK.

Thanks in advance

+4
source share
4 answers

As far as I understand, you need to convert make files to android :( format and use ndk_buidl to create them.

0
source

The only possible way is to write NDK make files. Many large libraries have been ported this way. Normally you should run configure script to create config.h and config.mak files. You will use config.mak to list your sources. There are programs on the network for porting some of the popular libraries that will be created with the Android NDK. I have had success with freetype, ffmpeg, SDL, DevIL etc.

0
source

You can use the following trick: download agcc , then compile your library with ./configure CC=agcc CXX=agcc --host=arm-linux-androideabi && make . After that, create a simple jni/Android.mk as follows:

 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 create your library using the ndk-build script.

0
source

More recent versions of ndk allow you to create a standalone toolchain that encapsulates most of the uniqueness of android so that it can be called more than regular gcc and support programs. This is somewhat suitable for use with existing project building systems - although configure scripts, which assume the ability to run test code of the target function on the host, will not work as in the case of cross-compilation.

0
source

Source: https://habr.com/ru/post/1308764/


All Articles