解决方法
如果你想让它工作,你需要在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.