HDFGroup / HDFGroup/hdf5

h5fc does not include `-I/usr/include` when installed to `/usr`

Open
#5,660 8 comments 0 reactions 1 assignee Claimed by @jhendersonHDF View on GitHub
Component - Build
Dominant language
C
Stars
988
Forks
355
Avg merge
4d 2h
Merged PRs (30d)
12

Description

**Describe the bug**
When hdf5 is installed to `/usr`, h5fc does not include the needed `-I/usr/include` path and fails to build programs, e.g.:

```
$ h5fc -c '/home/mgorny/git/meson/test cases/frameworks/25 hdf5/main.f90'
/home/mgorny/git/meson/test cases/frameworks/25 hdf5/main.f90:1:5:

1 | use hdf5
| 1
Fatal Error: Cannot open module file ‘hdf5.mod’ for reading at (1): No such file or directory
compilation terminated.
```

This is because `pkg-config` defaults to stripping system include paths, as they are not required by the C compiler — but they are required by the Fortran compiler.

**Expected behavior**
`h5fc` including `-I/usr/include` and compiling the program successfully.

I think the cleanest approach here would be to pass `--keep-system-cflags` to `pkg-config` — and indeed, if I patch `h5fc` to use it, it works again. I can make a pull request to add it to `h5fc` (via a substitution) if you agree to that approach.

**Platform (please complete the following information)**
- HDF5 version: 1.14.6, confirmed with f9ebbb9ab2cd4790c883ba4c5bad6614290b9728
- OS and version: Gentoo Linux amd64, Arch Linux amd64
- Compiler and version: GNU Fortran 14.3.0
- Build system (e.g. CMake version) and generator (e.g. XCode, Ninja): CMake / Ninja
- Any configure options you specified: `-G Ninja -DHDF5_BUILD_FORTRAN=ON -DCMAKE_INSTALL_PREFIX=/usr`
- MPI library and version (parallel HDF5): n/a

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.