HDF5 and undefined_reference

Hi,
I recently installed HDF5 1.8.5. I'm on Ubuntu with the latest GCC and I
want to work on some hdf files with the FORTRAN interface. I built HDF with
configure --prefix=dir -enable fortran -enable gcc and successfully
installed it. So I'm trying to compile the .f90 files in the example folder
but I get an undefined_reference error for every function I'm trying to
use.For example for the file "fileexample.f90"

/tmp/cci2V8j2.o: In function `MAIN__':
fileexample.f90:(.text+0x21): undefined reference to `__h5lib_MOD_h5open_f'
fileexample.f90:(.text+0x5b): undefined reference to `__h5f_MOD_h5fcreate_f'
fileexample.f90:(.text+0x6d): undefined reference to `__h5f_MOD_h5fclose_f'
fileexample.f90:(.text+0x78): undefined reference to `__h5lib_MOD_h5close_f'
collect2: ld returned 1 exit status

I'm not an experienced Linux user so I might be doing something wrong.I
checked some previous posts but didn't help.
Can you please tell me how I should compile the .f90 cause I think I'm
getting it wrong. I have been using NetCDF for some time and it has static
libraries in my usr/local/lib folder while HDF hasn't.All the HDF static
libraries are in my installation folder/lib while all the .mod and .h files
in installation folder/include. Should I install the libraries with install
.a /usr/local/lib or should I link the folder when I compile?

Thank you,
Euri.

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/HDF5-and-undefined-reference-tp2475757p2475757.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Euri,

Check the bin directory under the directory where you installed HDF5; there should a script with the name h5fc.

Use this script to compile fortran examples and see if it works.

<install>/bin/h5fc fileexample.f90

I think your compilation line doesn't point to the directory where Fortran module files are. Those should be under the <install>/include directory.

Elena

···

On Feb 11, 2011, at 12:50 PM, epik78 wrote:

Hi,
I recently installed HDF5 1.8.5. I'm on Ubuntu with the latest GCC and I
want to work on some hdf files with the FORTRAN interface. I built HDF with
configure --prefix=dir -enable fortran -enable gcc and successfully
installed it. So I'm trying to compile the .f90 files in the example folder
but I get an undefined_reference error for every function I'm trying to
use.For example for the file "fileexample.f90"

/tmp/cci2V8j2.o: In function `MAIN__':
fileexample.f90:(.text+0x21): undefined reference to `__h5lib_MOD_h5open_f'
fileexample.f90:(.text+0x5b): undefined reference to `__h5f_MOD_h5fcreate_f'
fileexample.f90:(.text+0x6d): undefined reference to `__h5f_MOD_h5fclose_f'
fileexample.f90:(.text+0x78): undefined reference to `__h5lib_MOD_h5close_f'
collect2: ld returned 1 exit status

I'm not an experienced Linux user so I might be doing something wrong.I
checked some previous posts but didn't help.
Can you please tell me how I should compile the .f90 cause I think I'm
getting it wrong. I have been using NetCDF for some time and it has static
libraries in my usr/local/lib folder while HDF hasn't.All the HDF static
libraries are in my installation folder/lib while all the .mod and .h files
in installation folder/include. Should I install the libraries with install
.a /usr/local/lib or should I link the folder when I compile?

Thank you,
Euri.
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/HDF5-and-undefined-reference-tp2475757p2475757.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Hey Elena,
thanks for your help. With your instructions I managed to build and run the
fileexample.f90 with:

sh h5fc fileexample.f90

My laptop has Ubuntu installed and the prefix directories in the h5fc file
were correctly pointing to
the lib and include folder.I also got it to build on my managed desktop
which runs scientific linux only
I had to edit the file to the correct directories.

So after creating some sample files I tried to read the data sets I wanted
and I realized that they were
.hdf and not .h5 which I suppose it means that I need HDF4.From what I read
they are not compatible plus I
have to work with f77 instead of f90.I also downloaded the HDF4 binaries and
didn't find any examples files like the
ones in HDF5 so I guess my chances are bleak.

Thanks for all the help anyway,at least I've started to work with HDF5.
Euri.

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/HDF5-and-undefined-reference-tp2475757p2480105.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Euri,

It is pretty easy to build HDF4 (and it will have a similar script called h4fc to help with linking all libraries). You can use the same fortran compiler you used to build HDF5.

You will need zlib and jpeg (version 6b) libraries installed on your machine. Source code (see http://www.hdfgroup.org/release4/obtain.html) comes with the detailed instructions how to configure and compile the HDF4 libraries and how to get the external libraries if your machine doesn't have them.

As for examples, the source code will have all examples that are found in the HDF4 User's Guide (see http://www.hdfgroup.org/doc.html). Check hdf/fortran/examples and mfhdf/fortran/examples directories in the source tree for Fortran examples. Examples are built and run when "make installcheck" is run, or you can use the h4fc script to compile an individual example. Be aware that there are dependencies between examples, they have to be run in the order specified in the makefiles (just check Makefile.am for the ordered list)

Examples are also available on-line at http://www.hdfgroup.org/tutorial4.html. We are working on providing a better interface to them (as we have for HDF5), so it would be easier to find them in the future.

Elena

···

On Feb 12, 2011, at 8:06 AM, epik78 wrote:

Hey Elena,
thanks for your help. With your instructions I managed to build and run the
fileexample.f90 with:

sh h5fc fileexample.f90

My laptop has Ubuntu installed and the prefix directories in the h5fc file
were correctly pointing to
the lib and include folder.I also got it to build on my managed desktop
which runs scientific linux only
I had to edit the file to the correct directories.

So after creating some sample files I tried to read the data sets I wanted
and I realized that they were
.hdf and not .h5 which I suppose it means that I need HDF4.From what I read
they are not compatible plus I
have to work with f77 instead of f90.I also downloaded the HDF4 binaries and
didn't find any examples files like the
ones in HDF5 so I guess my chances are bleak.

Thanks for all the help anyway,at least I've started to work with HDF5.
Euri.
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/HDF5-and-undefined-reference-tp2475757p2480105.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org