Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using eigen with android ndk

Has anybody successfully imported the eigen library using the ndk? I was thinking about using it to do all the math matrix operations for an app Im working on. I found a few people mentioning it in some forums but aside from the fact that I dont know if they successfully got it working most of the forums I read start off mentioning some error related to neon code.....which I havent messed with before either.

What would be really helpful is if some one can point me towards a tutorial on how to compile an existing library like eigen using the ndk. That way I can just do it for myself later on. I just now 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-intense reading ahead of me so Ill start that but mean time if some one could jump in and help with the compiling of native libraries for use with the ndk I would much appreciate it.

like image 847
James andresakis Avatar asked Dec 12 '11 02:12

James andresakis


People also ask

What can I do with Android NDK?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.

What compiler does Android NDK use?

Code written in C/C++ can be compiled to ARM, or x86 native code (or their 64-bit variants) using the Android Native Development Kit (NDK). The NDK uses the Clang compiler to compile C/C++.


2 Answers

I've never used the Android NDK before, I'm using Eigen for numeric calculations in physics.

Eigen is header only, so you can put it every where you like. You just have to set the include path to that folder( probably inside your Android.mk ). If you don't need the unsupported libraries in Eigen, then you only need the "Eigen" folder. The rest is only for documentation, and tests. After a short look at the documentation i think you can achieve that with

LOCAL_C_INCLUDES := path/to/eigen

inside your Android.mk

A quick and dirty solution would be to throw Eigen inside the 'jni' folder. But this only works if all the source using Eigen is there as well. This way you don't have to edit your Android.mk.

like image 171
P3trus Avatar answered Oct 21 '22 19:10

P3trus


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

/Users/foo/libraries/eigen/Eigen

Then, in your project's Android.mk file, tell ndk-build where the Eigen include files are:

LOCAL_C_INCLUDES += /Users/foo/libraries/eigen

Don't reference the actual "Eigen" folder here, reference the folder above it, otherwise the includes won't work. Finally, tell the eclipse indexer about the includes:

Right-click your project -> Properties -> C/C++ General -> Paths and Symbols -> Includes -> GNU C++ -> Add... -> File System... -> again point it to /Users/foo/libraries/eigen

Done.

like image 36
Amelie Mentor Avatar answered Oct 21 '22 20:10

Amelie Mentor