编译外部本机库

时间:2018-01-18 11:25:51

标签: android c++ android-ndk

我正在试图编译一个名为Eigen的本地外部库(包含.h文件),以便在我的App项目中使用它。为此,我尝试使用本指南Configure CMake配置我的CMakeList.txt文件。我一直在阅读很多博客和论坛,但由于我在Android NDK上很新,我不明白这些:

  1. 我是否需要一个名为Android.mk的文件才能将此库添加到我的项目中? 因为我重写了很多这个文件,但它并不存在于我的项目结构中
  2. 我在CMakeLists.txt中需要做哪些更改? 我试过补充说:

    //Sets lib_src_DIR to the path of the target CMake project.
    set( Eigen_src_DIR ../Eigen )
    //Sets lib_build_DIR to the path of the desired output directory.
    set( lib_build_DIR ../Eigen/output)
    file(MAKE_DIRECTORY ${lib_build_DIR})

    //Adds the CMakeLists.txt file located in the specified directory
    // as a build dependency.
    add_subdirectory( # Specifies the directory of the CMakeLists.txt file.
                  ${lib_src_DIR}
                  # Specifies the directory for the build outputs.
                  ${lib_build_DIR})

    // Adds the output of the additional CMake build as a prebuilt static library and names it lib_gmath. add_library( lib_eigen STATIC IMPORTED )
    set_target_properties( lib_eigen PROPERTIES IMPORTED_LOCATION
                       ${lib_build_DIR}/${ANDROID_ABI}/lib_eigen.a )
    include_directories( ${lib_src_DIR}/Eigen )

  3. 我已将此库中的文件夹放在../app/Eigen

0 个答案:

没有答案