【问题标题】:Use HDF5 from minGW on windows在 Windows 上使用来自 minGW 的 HDF5
【发布时间】:2015-04-10 18:46:17
【问题描述】:

我正在尝试使用 Fortran 程序编译并链接到 HDF5,但出现运行时错误。我已密切遵循此问题的答案中描述的程序

Use HDF5 from intel fortran on windows

我在环境变量中设置了 PATH,而不是在 Visual Studio 中设置它们。我将所有生成的 .mod 和 .lib 文件移动到我的项目文件夹中的 mod 和 lib 文件夹中。

在命令提示符下,我的编译器配置如下所示

 gfortran --version
 GNU Fortran (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 4.9.2
 gmake --version
 GNU Make 3.81

我的 makefile 看起来像

 ifdef SystemRoot
     PATHSEP2 = \\
 else
     PATHSEP2 = /
 endif
 PS = $(strip $(PATHSEP2))

 OBJ_DIR = obj
 MOD_DIR = mod
 LIB_DIR = lib

 FC      = gfortran
 FCFLAGS = -I$(MOD_DIR) -g -Wall
 FLFLAGS = -I$(MOD_DIR) -L$(LIB_DIR) -l$(LIB_DIR)hdf5_fortran

 SRCS_F = testHDF5.f90

 TARGET = testHDF5

 all: $(TARGET)

 testHDF5: testHDF5.f90 
  $(FC) -o $@ testHDF5.f90 $(FLFLAGS)

 $(OBJ_DIR)$(PS)%.o: %.f90
  $(FC) $(FCFLAGS) -c -o $@ $<

由于我在这里阅读的内容,我已将 hdf5_fortran.lib 更改为 libhdf5_fortran.lib

http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use

当我运行 gmake 时,我得到了

 gfortran -o testHDF5 testHDF5.f90 -Imod -Llib -llibhdf5_fortran

当我尝试运行可执行文件时,会弹出一个窗口,显示“应用程序无法正确启动 (0xc000007b)。单击确定关闭应用程序。”

这个链接

http://www.solveinweb.com/solved-the-application-was-unable-to-start-correctly-0xc000007b-click-ok-to-close-the-application/

建议是32位到64位不兼容造成的。我使用的是 64 位机器,我确实下载了 32 位版本的 CMake,但这只是因为似乎没有 64 位机器的可用版本。另外,这个链接

http://www.cmake.org/pipermail/cmake/2010-September/039375.html

建议它应该不重要。所以我的问题是,我哪里出错了?到目前为止,我所展示的内容是否存在明显错误?

更新:

我发现运行时错误是由于未指定路径,在本例中为 HDF5_DIR。在 USING_HDF5_CMAKE 文档中,它说要指定环境变量

 HDF5_DIR=C:/Program Files/HDF_Group/HDF5/1.8.x/cmake/hdf5

这解决了应用程序一开始就崩溃的问题。但是现在,我得到了错误

 HDF5-DIAG: Error detected in HDF5 (1.8.14) thread 0:
   #000: C:\Users\Charlie\Downloads\CMake\hdf5-1.8.14\src\H5D.c line 167 in H5Dcr
 eate2(): not a datatype ID
     major: Invalid arguments to routine
     minor: Inappropriate type
 HDF5-DIAG: Error detected in HDF5 (1.8.14) thread 0:
   #000: C:\Users\Charlie\Downloads\CMake\hdf5-1.8.14\src\H5D.c line 415 in H5Dcl
 ose(): not a dataset
     major: Invalid arguments to routine
     minor: Inappropriate type

我猜是第一个错误

 HDF5-DIAG: Error detected in HDF5 (1.8.14) thread 0:
   #000: C:\Users\Charlie\Downloads\CMake\hdf5-1.8.14\src\H5D.c line 167 in H5Dcr
 eate2(): not a datatype ID
     major: Invalid arguments to routine
     minor: Inappropriate type

是最重要的,因为它可能会触发后面的。根据这个线程

http://hdf-forum.184993.n3.nabble.com/HDF5-Fortran-Fail-to-execute-of-a-basic-F90-program-td4026778.html

建议使用与构建 fortran 源代码相同的编译器来构建库(如果我没记错的话)。在使用 CMake 构建期间,我指定使用 MinGW,我相信在两个构建期间都会使用它,对吗?

再次感谢您对此提供的任何帮助。

【问题讨论】:

    标签: compilation makefile linker fortran gfortran


    【解决方案1】:

    我就这个问题联系了 hdf5 支持

     Platform/OS:
     Windows 7
    
     Product/Version:
     HDF5, Latest download
    
     Description:
     Hi, I'm having trouble getting HDF5 working on my windows machine with fortran. Below is an outline of what I've done, and after I show the error I get. 
    
     1.1) Download and install CMake, Windows (Win 32 Installer) from http://www.cmake.org/download/ 
    
     1.2) I did not add CMake to the system PATH, because it was too long. 
    
     1.3) I manually added "C:/Program Files (x86)/CMake/bin" to the PATH (for user)
     in computer->properties->advanced system settings->environment variables 2.1) Download and install HDF5 
    
     2.2) I manually added "C:/Program Files/HDF Group/HDF5/1.8.14/cmake/hdf5" to the PATH (for user) in computer->properties->advanced system settings->environment variables 
    
     3.1) I created a new, empty, directory (/Project/) and copied HDF5Examples-0.1.1-Source.zip and HDF518 Examples.CMAKE to it. 3.1) Downloaded hdf5-CMakeWindows.zip from http://www.hdfgroup.org/HDF5/release/cmakebuild.html and unzipped
     file to find a folder named CMake. 
    
     3.2) Opened CMake GUI, set Source Code Dir = CMake/hdf5-1.8.14 folder 
    
     3.3) Set Where to build binaries Dir = /Project/ (project folder containing HDF5Examples-0.1.1-Source.zip and HDF518 Examples.CMAKE) 
    
     4.1) In the CMake GUI, I pressed Configure, (selected MinGW and default from the 1st and 2nd drop down respectively), Configure. Checked BUILD_SHARED_LIBS and HDF5_BUILD_FORTRAN. Configure, configure, generate. 
    
     4.2) I navigated to the bin directory of the CMake folder and copied the library files, .dll files, and .mod files to an empty test folder (/test_HDF5/), where I separated them into lib/mod folders. 
    
     4.3) I created a makefile which, if done correctly, linked the .lib files. 
    
     4.4) I compiled the files and linked the libraries and there seemed to be no errors, nor warnings. When running the testHDF5.exe I received the following error: The application was unable to start correctly (0xc000007b). Click OK to close the application. I believe this is a configuration issue, and I'm not sure how to resolve it. 
    
     I'm very new with linking libraries and I'm just trying to use HDF5 as a data exporting tool with my existing fortran code. Any help is greatly appreciated. 
    
     Sincerely, Charlie Kawczynski
    

    他们的回应是,截至 2015 年 4 月 14 日,MinGW 不受支持:

     Hi Charlie,
    
     We do not support MinGW at this time. The developer had tried
     building with Fortran and was not able to get it to work.
    
     We do have a user forum where you can post questions. However, others
     have posted issues about MinGW and Fortran that have not been resolved. :(
    
     For information on the HDF Forum, see:
        http://www.hdfgroup.org/services/community_support.html
    
     -Barbara
    

    希望这对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 2013-12-01
      • 2014-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多