Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to develop/port a native C library to android?

So, I have a little C library. I want to make this library available to other devs that develop native C code in android (other libraries, native apps etc).

What's the best way to go? I don't really have much clue yet, trying to figure all this out.

I've read that there are two paths to go with the NDK: using Android.mk and using create-standalone-toolchain -- is this correct? How does each one of these works? Is there a third way without the NDK, and should this be used now that the NDK is available?

** This may have been asked before, but I understand things have changed since the release of the NDK, as a lot of posts I find seem obsolete.

like image 966
frustrated_nick Avatar asked Jul 24 '12 14:07

frustrated_nick


1 Answers

this question can have a Huge answer, I will try to be as brief as possible.

  1. Using the Android NDK, make a new android project, create a JNI folder, and create an Android.mk file, in it, make two libs, one being your lib, exported as a shared lib and the other, a jniwrapper that will test it. Here is an example of how it was done by a guy for his own lib.

  2. You can make a shared lib by compiling with the standalone toolchain, here is an article on the subject and also take a look at the curl Readme for android, it explains how to compile curl for Android using the standalone toolchain, I believe it's the better way to do it, and also to easier for you since you will use the cross-compiler in a regular fasion...

like image 159
Tancho Avatar answered Oct 14 '22 03:10

Tancho