Closed nyckmaia closed 4 years ago
Sorry about that...
I forgot to link the h5fortran.lib
...
Now it works great!
I think Intel Fortran on Windows is the trickiest linking situation for HDF5, but one that does work as you see. I also regularly using HDF5 + h5fortran with Intel compiler or GCC on Windows.
In general, the easiest way to use h5fortran cross platform is to use CMake. Then if your program above is named "main.f90" the CMakeLists.txt for your project is like
cmake_minimum_required(VERSION 3.14)
project(MyTest Fortran)
include(FetchContent)
FetchContent_Declare(h5fortran_proj
GIT_REPOSITORY https://github.com/geospace-code/h5fortran.git
GIT_TAG v2.11.1
)
FetchContent_MakeAvailable(h5fortran_proj)
# ------------------------------------------------------
add_executable(my_program main.f90)
target_link_libraries(my_program h5fortran::h5fortran)
this would be built like:
cmake -B build
cmake --build build
which creates executable "build/my_program.exe"
This question has come up a few times, I think I will make a simple standalone example for this under Examples/
I wrote a simple Fortran static library using thi single
*.f90
file:After that, I call the
f_x
subroutine in my C++ application:Library Directory:
C:\HDF5\1.12.0\lib
Include Directory:C:\HDF5\1.12.0\include
Linked HDF5 libraries:
lib
prefix versions:Of course, I linked my own generated Fortran static library
Lib1.lib
and a single Fortran library dependence calledifmodintr.lib
But I got this compile time error below:
Could you help me?
How can I fix it?
My system: