Compiling the Plotting Package ld: cannot find -lhdf5_hl

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
zangzhipeng
Posts: 12
Joined: Wed Dec 10, 2008 10:15 pm
Location: The University of Western Australia

Compiling the Plotting Package ld: cannot find -lhdf5_hl

#1 Unread post by zangzhipeng »

Hello, everyone
When I was compiling the plotting package, i came across some problems. I issued the make command to generate the executables,and the error occured as below:

zang@zang:~/Program/Mydir/src$ make

/usr/bin/g95 -O3 -ffast-math \
cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/zang/bin/cnt \
libUTIL.a -L/usr/local/lib -lncarg -lncarg_gks -lncarg_c -L/usr/X11R6/lib64 -lX11 -L/opt/g95soft/s_netcdf4/lib -lnetcdf -L/opt/g95soft/s_hdf5/lib -lhdf5_hl -lhdf5 -lz

ld: Warning: size of symbol `mapcm1_' changed from 48 in libUTIL.a(hbackground.o) to 40 in /usr/local/lib/libncarg.a(mapbd.o)

ld: cannot find -lhdf5_hl

make: *** [/home/zang/bin/cnt] Error 1

So can anyone help me about this or give me some advise for the possible causes. Many thanks!

Cheers!
Zhipeng

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: Compiling the Plotting Package ld: cannot find -lhdf5_hl

#2 Unread post by m.hadfield »

If you look at the end of the command that failed you will see the following arguments

Code: Select all

-L/opt/g95soft/s_netcdf4/lib -lnetcdf -L/opt/g95soft/s_hdf5/lib -lhdf5_hl -lhdf5 -lz
These tell the linker to link to the netCDF and HDF5 libraries. Something is wrong with these arguments: either you do not have a library called libhdf5_hl.a or it is not in any of the directories searched by the linker.

The linker command is contructed by the platform-specific make file. I'm guessing in your case it's this one. The variables used in constructing this part of the linker command are USE_NETCDF4, NETCDF_LIBDIR and HDF5_LIBDIR. You need to set these explicitly if the defaults are not appropriate for your system.

The most likely problem is that USE_NETCDF4 is defined (i.e. it exists and has a non-empty value) when you don't have a netCDF 4 library. This is the default setting, imposed by the following line in makefile:

Code: Select all

USE_NETCDF4 ?= on
You can override this by invoking make as follows

Code: Select all

make USE_NETCDF4=""
You may also need to specify NETCDF_LIBDIR and NETCDF_INCDIR to non-default values.

mariafattorini
Posts: 52
Joined: Tue Mar 03, 2009 2:39 pm
Location: C.N.R. - LaMMA

Re: Compiling the Plotting Package ld: cannot find -lhdf5_hl

#3 Unread post by mariafattorini »

Dear all,

I have a problem with the installation of the Plotting Package with Cygwin (my PC is a Window Vista).

First I have installed a precompiled binary NCL (version 5.1.0) following the procedure on the web page http://www.ncl.ucar.edu/Download/cygwin.shtml.During this operation I don’t find the sh-utils cygwin’s library. However I continued the installation and did the final test NCL with success.

Then I followed the procedure of Tutorial to install the plotting package (https://www.myroms.org/wiki/index.php/P ... stallation).
I opened the makefile in the directory "/home/MyDir/src" and I set the macro “FORT ?=” with “gfortran” because I compiler the ROMS with gfortran4 (see the tutorial in wikiroms to install ROMS in Windows Vista by Cygwin).
I naturally added the “CYGWIN-gfortran.mk” (that I have taken from the directory “/home/roms/trunk/Compilers) in the directory “/home/MyDir/src/Compilers”.
In Cygwin at the directory “home/MyDir/src”, I typed “make” to compiler the plotting package and the following lines appeared:

/usr/bin/gfortran-4 -frepack-arrays -O3 -ffast-math \
cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/maria/bin/
cnt \
libUTIL.a -L/usr/local/netcdf4/lib -lnetcdf -L/usr/local/hdf5/lib -lhdf
5_hl -lhdf5 -lz
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../i686-pc-cygwin/bin/ld: cannot find
-lhdf5_hl
collect2: ld returned 1 exit status
make: *** [/home/maria/bin/cnt] Error 1


I then tried typing make USE_NETCDF4=""; I write following some lines that appeared:

/usr/bin/gfortran-4 -c -frepack-arrays -O3 -ffast-math csec.f90
/usr/bin/gfortran-4 -frepack-arrays -O3 -ffast-math \
csec.o cpmpxz2d.o -o /home/maria/bin/csec libUTIL.a -L/usr/local/lib -l
netcdf


[...]

libUTIL.a(cnt_frame.o):cnt_frame.f:(.text+0x651): undefined reference to `_e_wsf
e'
libUTIL.a(cnt_frame.o):cnt_frame.f:(.text+0x65d): undefined reference to `_s_wsf
e'
libUTIL.a(cnt_frame.o):cnt_frame.f:(.text+0x67b): undefined reference to `_do_fi
o'
libUTIL.a(cnt_frame.o):cnt_frame.f:(.text+0x680): undefined reference to `_e_wsf
e'
libUTIL.a(cnt_frame.o):cnt_frame.f:(.text+0x725): undefined reference to `_s_wsf
e'
libUTIL.a(cnt_frame.o):cnt_frame.f:(.text+0x748): undefined reference to `_do_fi
o'
libUTIL.a(cnt_frame.o):cnt_frame.f:(.text+0x74d): undefined reference to `_e_wsf


[...]

Please, may you help me?
Thanks,
maria

User avatar
arango
Site Admin
Posts: 1361
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: Compiling the Plotting Package ld: cannot find -lhdf5_hl

#4 Unread post by arango »

The plotting package cannot be run in parallel :!: You need to compile the package to run in serial :!: This means that you either use the NetCDF 3.x library or the serial NetCDF 4.x library (if USE_NETCDF4). If using the NetCDF 4.x library, you need to compile these library and disable parallel support. That is, you cannot compile with MPI (mpif90). This means that you need to have serial and parallel version of the NetCDF 4.X library. The serial is used in the plotting package. Both the serial and parallel versions of these library can be used in ROMS.

Since the NetCDF libraries are backward compatible and you just need to compile the plotting package once, it advantageous to compile the the plotting package with the NetCDF 4.x library.

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: Compiling the Plotting Package ld: cannot find -lhdf5_hl

#5 Unread post by m.hadfield »

Hernan, I'm puzzled by your statement that the plotting package cannot be compiled for parallel operation. While I'm sure this is true, I see no evidence that mariafattorini is trying to do this.

Maria, the symbols that the loader can't find (_e_wsfe, _s_wsfe, _do_fio) are not associated with netCDF. Do you know what library or object file is supposed to contain them? Are they from some other routine in the plotting package code, perhaps? Did you delete all the object files from the first, unsuccessful attempt at running make before trying again? This is always a good idea.

mariafattorini
Posts: 52
Joined: Tue Mar 03, 2009 2:39 pm
Location: C.N.R. - LaMMA

Re: Compiling the Plotting Package ld: cannot find -lhdf5_hl

#6 Unread post by mariafattorini »

Hello,

many thanks for the above replies.

I have deleted the previous installation and I installed the Plotting Package again.

I installed the binary's NCL 5.0.1 and I downloaded the Plotting Package in Mydir directory.
I followed the indications of the Tutorial (web page: https://www.myroms.org/wiki/index.php/P ... stallation). I modified the makefile located in the "/home/Mydir/src" directory as following:
I set "fort ?= gfortran" (because I used gfortran-4 to compile ROMS) and I added the CYGWIN-gfortran.mk in the "home/Mydir/src/Compilers" directory.

Typing "make" from CYGWIN'command line, I obtain the following lines:

$ make
/usr/bin/cpp -P -traditional -DCYGWIN -DI686 -DGFORTRAN -DNCARG441 -Drmdocinc -I
Include -IUtility Drivers/cnt.F > cnt.f90
cnt.f90
cnt.f90: line 1: PROGRAM: command not found
cnt.f90: line 2: syntax error near unexpected token `newline'
cnt.f90: line 2: `!'
make: *** [cnt.f90] Error 2



If I type "make" again, I obtain the following lines:

$ make
/usr/bin/gfortran-4 -c -frepack-arrays -O3 -ffast-math cnt.f90
/usr/bin/cpp -P -traditional -DCYGWIN -DI686 -DGFORTRAN -DNCARG441 -Drmdocinc -I
Include -IUtility Utility/cpmpxy2d.F > cpmpxy2d.f90
cpmpxy2d.f90
cpmpxy2d.f90: line 1: syntax error near unexpected token `('
cpmpxy2d.f90: line 1: ` SUBROUTINE cpmpxy(imap,xinp,yinp,xotp,yotp)'
make: *** [cpmpxy2d.f90] Error 2


Then I open the "CYGWIN-gfortran.mk" file and I change "FFLAGS := -frepack-arrays" to "FFLAGS ?=-fno-second-underscore", but I obatin the same things.

I think that the problem is in the "Machine depending include file" section of the Tutorial and in particular in the sets of LD, ncargf90, NETCDF_INCDIR and NETCDF_LIBDIR.
Furthermore, I have not a "LD" in my "CYGWIN-gfortran.mk" file, but I can set only LDFLAG (default is set "LDFLAGS := ").


What should I do for a proper setting?

Thanks very much,
Maria

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: Compiling the Plotting Package ld: cannot find -lhdf5_hl

#7 Unread post by m.hadfield »

You should look carefully at the files in question (Drivers/cnt.F, cnt.f90, Utility/cpmpxy2d.F, cpmpxy2d.f90) to work out why the syntax error is occurring.

This has nothing to do with FFLAGS or LD settings. It's occurring before that.

How did you download the plotting package? I'm inclined to suspect you used a non-Cygwin tool, which has saved the source code in DOS/Windows text format, ie with each line terminated by CR LF instead of LF. If so, you can fix this with the Cygwin dos2unix utility.

Post Reply