将本征库添加到Android NDK [英] Add Eigen Library to Android NDK

查看:84
本文介绍了将本征库添加到Android NDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的Android Studio项目中包含Eigen库,以执行一些线性代数运算,并使用一些我为桌面开发的C ++代码.我一直在寻找有关此主题的信息,但所涉及的内容还不太多,而且我还是Android NDK的新手. Eigen库不需要编译,所以我认为这很容易,但是我缺少了一些东西.我尝试将Eigen文件夹(包含所有包含项)复制到NDK文件夹(.. \ Android \ Sdk \ ndk-bundle \ sysroot \ usr \ include)中,其中还有其他外部库(例如GLES),但是Android Studio不会检测到它.我该怎么做??预先谢谢你,我真的很需要这个.

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.

您可以在此处看到,包含了Eigen lib,但是当我编译项目时,会出现很多错误,并且我不知道为什么有什么想法吗?

推荐答案

最后,我达到了目标,并且正在使用Android中的Eigen.如果您想在Android中使用Eigen库,希望对您有所帮助:

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:

  1. 从官方网站下载Eigen库.
  2. 在已下载的zip文件中复制Eigen文件夹,其中包含所有 库的标题(.h文件)并将其粘贴到您选择的一个文件夹中 在项目中.例如,我在以下方面做到了:
  1. Download Eigen library from the official site.
  2. 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

../app/src/main/cpp

  • 编辑CMakeLists.txt,并将此行与Eigen文件夹的路径添加在一起 在您的项目中: include_directories(src/main/cpp/Eigen)
  • 在真实设备中启动应用程序(不能在模拟器上运行)以加载本征 头文件.
  • 在cpp文件中包含Eigen标头,并可以正常使用它们.例如:

  • 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; }

    #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; }

    对于我来说,我不需要编译任何东西,可以使用官方Eigen库的头文件

    这篇关于将本征库添加到Android NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆