Using native with android ndk

Has anyone successfully imported their own library using ndk? I was thinking about using this to do all the math matrix operations for the application I'm working on. I found that some people mention this in some forums, but besides the fact that I do not know if they worked successfully, most of the forums I read start to mention some error related to neon code ..... which I did not spoil before or.

Which would be really useful if someone could point me to a tutorial on how to compile an existing library, for example using ndk. That way, I can just do it for myself later. I just found this: http://code.google.com/p/android-cmake/ and would like to try to implement it myself, but not sure where to start. Obviously, I have some semi-intensive reading ahead of me, so I'm starting this, but I mean the time, if someone can jump in and help with compiling the native libraries for use with ndk, I would really appreciate it.

+6
source share
2 answers

I have never used the Android NDK before, I use Eigen for numerical calculations in physics.

Eigen is just a headline, so you can put it wherever you want. You just need to set the path to include in this folder (perhaps in your Android.mk). If you do not need unsupported libraries in Eigen, you only need the "Eigen" folder. The rest is for documentation and tests only. After a brief review of the documentation, I think you can achieve this with

LOCAL_C_INCLUDES := path/to/eigen 

inside your Android.mk

A quick and dirty solution is to drop Eigen into the jni folder. But this only works if all sources using Eigen also exist. Thus, you do not need to edit your Android.mk.

+3
source

I prefer having Eigen headers outside of the Eclipse workspace , like stl etc. To do this, unzip your Eigen download and copy the "Eigen" folder to the directory of your choice:

/ Users / Foo / libraries / native / Eigen

Then, in the Android.mk project file, specify ndk-build, where are the Eigen-enabled files:

LOCAL_C_INCLUDES + = / Users / foo / libraries / eigen

Do not link to the actual "Eigen" folder here, link to the folder above it, otherwise included ones will not work. Finally, report that the eclipse indexer about this includes:

Right click on your project -> Properties -> C / C ++ General -> Outlines and Symbols -> Includes -> GNU C ++ -> Add ... -> File System ... -> point to it again / Users / Foo / libraries / native

Done.

+1
source

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


All Articles