Android上支持HDF5

如何在 Android上使用 HDF5 software?可以为Android平台编译本机C库,然后使用HDF5 Java绑定调用吗?

解决方法

您不能(轻松)使用Android的交叉编译器进行编译

如果你想让它工作,你需要在ARM设备上编译,特别是Android工具链.老实说,不要在NDK项目中使用HDF5,因为即使你设法生成二进制文件不支持.

我继续尝试使用NDK-CMake-gradle编译它,但它没有尝试找出各种类型的大小.我以前见过这种行为,它通常需要将可执行文件上传到模拟器或设备,运行它并读回结果.不酷.

根据自己的FAQ

No,there are two problems with cross-compiling in HDF5.

First,HDF5 uses AC_TRY_RUN in several places. This macro tries to
compile and run a test program,but this does not work for
cross-compiling because it builds the program for the host system,and
tries to run it on the build system. To resolve this the macros would
need to be replaced with a a non-dynamic test (that is,determine the
correct setting without executing a test program),or amend each
AC_TRY_RUN with an argument telling it what to do when cross-compiling
(which would likely mean setting a pessimistic default for
cross-compilations).

Many of these AC_TRY_RUN instances are for checks of compiler
capabilities. For example,HDF5 checks to see if the Fortran compiler
supports the intrinsic function “SIZEOF” by running a test program.
Based on the result,a makefile conditional is set to toggle which
source file to use when building H5test_kind (in this case,either
H5test_kind_SIZEOF.f90 or H5test_kind.f90). There are also many C++
compiler checks. Other AC_TRY_RUN checks include: checking if large
files are supported,checking if SZIP compression can encode,checking
if gettimeofday uses the timezone struct,and many more for checking
conversion capabilities.

The second (dealbreaking?) problem is the generation of H5tinit.c and,
to a lesser extent,H5libsettings.c which are actually generated
within ‘make’,not by configure. The programs that generate them are C
programs which are compiled to run on the target platform,but they
are then run during ‘make’ on the build platform,and thus fail (or,
in some cases,simply produce incorrect results). HDF5 would need to
generate these source files during configure without executing a
machine-dependent program on the build system. (In other words for
H5tinit.c,HDF5 would need to do what H5detect does,but in a
scripting language that can be run during configure on the build
platform. Since h5detect is supposed to detect machine byte order and
floating point format on the target platform,there is not currently a
solution for this.)

解决这个问题的老方法

我已经发布了相当长的指令来解决这些问题,并将其作为一个名为Android HDF5 Compilation How-to的要点进行编译.

我已经针对v1.8.18测试了这个公式,它仍然有效.这是我写的script作为驱动编译armeabi,armeabi-v7a和x86的起点.

虽然在测试中,某些库函数似乎存在导致崩溃的问题,但正如我最初所说,如果你无法使编译干净利落,你应该避免使用HDF5.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...