I need to include Eigen library in my Android Studio project to do some linear algebra operations and use some C++ code that I've developed for desktop. I've been looking for information on this topic, but there isn't too much and I'm new on Android NDK. Eigen library doesn't need to be compiled, so I thought It would be easy, but I'm missing something. I've tried to copy the Eigen folder (which have all the includes) into the NDK folder (..\Android\Sdk\ndk-bundle\sysroot\usr\include) where there are other exteral libraries (GLES for example) but Android Studio don't detect it. How can I do it?? Thank you in advance, I really need this.
Edit 1: As you can see here, Eigen lib is included, but when I compile the project there are many errors, and I don't know why. Any ideas?
Finally I reach my objective, and I'm Working with Eigen in Android. If you are triying to use Eigen library in Android, I hope this help you:
../app/src/main/cpp
include_directories(src/main/cpp/Eigen)
Include in your cpp file the Eigen headers and work with them normally. For example:
#include "Eigen/Dense"
void multiply2Matrices(){
Eigen::MatrixXd M(2,2);
Eigen::MatrixXd V(2,2);
for (int i = 0; i<=1; i++){
for (int j = 0; j<=1; j++){
M(i,j) = 1;
V(i,j) = 2;
}
}
Eigen::MatrixXd Result = M*V;
}
In my case, I didn't have to compile anything, jus use the header files of official Eigen library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With