Issue
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.
Solution
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:
- Download Eigen library from the official site.
- Copy Eigen folder inside the zip you have downloaded in which are all the
headers (.h files) of the library and paste it on one folder of your choice
in the project. For example, i did it in:
../app/src/main/cpp
- Edit CMakeLists.txt, adding this line with the path of the Eigen folder
inside your project:
include_directories(src/main/cpp/Eigen) - Launch the App in a real device (not working on emulator) to load the Eigen header files in it.
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
Answered By - edusan1213
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.