Android NDK Include Eigen
An answer to this question on Stack Overflow.
Question
I am trying to include the Eigen3 library in an Android project so I can do some Matrix math in native code.
When I compile my project it complains:
In file included from jni/Eigen/Dense:1:0,
from jni/Ares.cpp:9:
jni/Eigen/Core:156:22: fatal error: functional: No such file or directory
#include <functional>
^
compilation terminated.
I thought maybe including the STL would help, so I have an Application.mk file which is as follows:
APP_STL := gnustl_static
No dice, though.
Adding /usr/include/c++/4.9.2/ to my LOCAL_C_INCLUDES variable resolves that error, but raises:
In file included from jni/Eigen/Core:152:0,
from jni/Eigen/Dense:1,
from jni/Ares.cpp:9:
/usr/include/c++/4.9.2/cstdlib:41:28: fatal error: bits/c++config.h: No such file or directory
#include <bits/c++config.h>
Is there a way to include Eigen and resolve these issues other than progressively adding most of my machine's headers?
Answer
The following resolved the aforementioned issue!
Create a file called
Application.mkin the directoryprojet_dir/jni/(so it isprojet_dir/jni/Application.mk).Add the following line to that file
APP_STL:=stlport_static
If you run into a shared_ptr error, try using
APP_STL := gnustl_staticinstead.