gpt4 book ai didi

android - Android 上的 HDF5 支持

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:11:51 25 4
gpt4 key购买 nike

如何使用 HDF5 software在安卓上?能否为 Android 平台编译原生 C++ 库,然后使用 HDF5 Java 绑定(bind)调用?

最佳答案

您不能(轻易)使用 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我写的是驱动 armeabiarmeabi-v7ax86 编译的起点。

虽然在测试中,某些库函数似乎存在导致崩溃的问题,因此正如我最初所说的,如果您无法使编译正常工作,您应该避免使用 HDF5。

关于android - Android 上的 HDF5 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15282410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com