Richard
Richard

Reputation: 61439

Android NDK Include Eigen

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?

Upvotes: 0

Views: 1477

Answers (1)

Richard
Richard

Reputation: 61439

The following resolved the aforementioned issue!

  1. Create a file called Application.mk in the directory projet_dir/jni/ (so it is projet_dir/jni/Application.mk).

  2. Add the following line to that file

    APP_STL:=stlport_static
    
  3. If you run into a shared_ptr error, try using APP_STL := gnustl_static instead.

Upvotes: 1

Related Questions