[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #FTD-335729]: netcdf F90 - trouble linking



Tim,

Just to make sure you're not using old object files that were compiled
in an earlier build with different flags to gfortran, I'd like you to
run the following commands in the netCDF examples/F90 directory, to
compile the example program from source and then link it with the
library.  I'm also showing the output I see when I run these commands:

 $ gfortran -I../../f90 -g -O2 -c pres_temp_4D_rd.f90
 $ gfortran -g -O2 pres_temp_4D_rd.o ../../libsrc/.libs/libnetcdf.a -o
 pres_temp_4D_rd
 $ ls -l pres_temp_4D_rd.o pres_temp_4D_rd
 -rwxrw-r-x   1 russ     ustaff   1111472 Nov  5 12:27 pres_temp_4D_rd
 -rw-rw-r--   1 russ     ustaff      7540 Nov  5 12:27 pres_temp_4D_rd.o
 $ ./pres_temp_4D_rd
  *** SUCCESS reading example file pres_temp_4D.nc!

This example program calls both nf90_open and nf90_strerror, so if the
above works, but your application linked against the same library as
used in the above doesn't work because it can't find nf90_open and
nf90_strerror, then maybe it's trying to link dynamically with a
different shared library that prevents it from linking with the
library you specify.

Try running the "ldd" command, if you have it, to see where the
dynamic linker is looking for libraries, like this:

 $ ldd pres_temp_4D_rd
        libgfortran.so.0 =>      /opt/csw/gcc4/lib/libgfortran.so.0
        libm.so.2 =>     /lib/libm.so.2
        libgcc_s.so.1 =>         /opt/csw/gcc4/lib/libgcc_s.so.1
        libc.so.1 =>     /lib/libc.so.1
        libm.so.1 =>     /lib/libm.so.1
        libgcc_s.so.1 =>         /opt/csw/lib/libgcc_s.so.1

Notice there is no netCDF library in the above list of shared object
libraries, which is good, because it shows we linked to the static
netCDF library, not some dynamic library gotten from, for example, the
LD_LIBRARY_PATH environment variable.  If you see a netCDF library in
th above list, try checking your LD_LIBRARY_PATH environment variable
and removing any netCDF libraries found there, then trying again.

The next step would be to try building SiBD3 again with your new
LD_LIBRARY_PATH environment and see if that makes a difference.

I'm also assuming your
  /home3/twh142/netcdf-3.6.2/libsrc/.libs/libnetcdf.a
is the same file as
  ../../libsrc/.libs/libnetcdf.a
that you're linking against in the example program above.  You might
compare them, just to make sure.

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: FTD-335729
Department: Support netCDF
Priority: Normal
Status: Closed