HDF4 undefined reference on redhat 8

I have an old fortran program that reads a .hdf file. I can compile/link on redhat 7 but not working on redhat 8.

I have installed hdf.x86_64, hdf-devel.x86_64, hdf-static.x86_64 from epel repository. The lib files are in /usr/lib64. The include files are in /usr/inlcude and /usr/include/hdf. (I also have installed hdf5 libraries too.)

I can compile the file on command line:
gfortran -std=legacy new_summary.f -I/usr/include -I/usr/include/hdf -L/usr/lib64 -lmfhdf -ldf -ljpeg -lz -lnetcdff
I have also tried using h4fc and got the same error messages.

I got a long list of errors about undefined reference

/home/jzheng/work/linux/new_summary/src/…/…/…/trunk/new_summary/src/new_summary.f:1042: undefined reference to sfrattr_' /home/jzheng/work/linux/new_summary/src/../../../trunk/new_summary/src/new_summary.f:1016: undefined reference tosfgainfo_’
/home/jzheng/work/linux/new_summary/src/…/…/…/trunk/new_summary/src/new_summary.f:1036: undefined reference to sfrattr_' /home/jzheng/work/linux/new_summary/src/../../../trunk/new_summary/src/new_summary.f:1029: undefined reference tosfrattr_’
/home/jzheng/work/linux/new_summary/src/…/…/…/trunk/new_summary/src/new_summary.f:1022: undefined reference to sfrattr_' new_summary.o: In functionget_global_attributes_’:
/home/jzheng/work/linux/new_summary/src/…/…/…/trunk/new_summary/src/new_summary.f:929: undefined reference to sfstart_' /home/jzheng/work/linux/new_summary/src/../../../trunk/new_summary/src/new_summary.f:940: undefined reference tosffinfo_’
new_summary.o: In function get_sds_info_': /home/jzheng/work/linux/new_summary/src/../../../trunk/new_summary/src/new_summary.f:968: undefined reference tosfn2index_’
/home/jzheng/work/linux/new_summary/src/…/…/…/trunk/new_summary/src/new_summary.f:971: undefined reference to sfselect_' /home/jzheng/work/linux/new_summary/src/../../../trunk/new_summary/src/new_summary.f:982: undefined reference tosfginfo_’
… …

These are all defined somewhere in the hdf include files. The linking must have failed, but I don’t see why or how.

Has anyone ran into similar problems?

Thank you for your time,
Jian