0

I have the problem of linking the HDF-EOS library to a Fortran90 program. I have compiled the library from source to a directory specified in $prefix. My simple compile command is:

gfortran -I$prefix/include -L$prefix/lib -Wl,-rpath -Wl,$prefix/lib -lhdfeos -lGctp -lmfhdf -ldf -lz -lsz -ljpeg tst.f90

When compiling, I get the following error:

undefined reference to `gdopen_'

In the program, which I am not supposed to change, the HDF-EOS library is used via the external keyword, e.g.

integer(kind=4), external :: gdopen

In the library, nm $prefix/lib/libhdfeos.a | grep gdopen gives me:

00000000000120c0 T gdopen

When compiling with -fno-underscoring, I get just a different error:

gfortran -fno-underscoring -I$prefix/include -L$prefix/lib -Wl,-rpath -Wl,$prefix/lib -lhdfeos -lGctp -lmfhdf -ldf -lz -lsz -ljpeg tst.f90

the error is then:

undefined reference to `gdopen'

Also, gfortran finds the libraries, otherwise it would complain. Is the error related to the underscore? What else can I try? I work on Fedora and gfortran version 4.7.2.

Andre
  • 427
  • 4
  • 17

1 Answers1

1

Yes, very likely to be caused by the underscore.

Try compiling with -fno-underscoring (https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html), but fixing it by a proper bind(C) interface would be better.

This tutorial (Did you read it before going here? Very easy to find even for a complete novice in the library, like me.) also states you should use -fno-underscoring.

Continue by implementing the rest what the tutorial recommends, including compiling with FC=$(HDF4_DIR)/bin/h4fc.