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

[netCDF #YTJ-181465]: nf_test in netcdf-fortran-4.2 fails with undefined reference

Hi Dennis,

> Package Version: netcdf-fortran-4.2
> Operating System: CentOS 5.8
> Hardware:
> Description of problem:
> I have a problem getting nf_test in netcdf-fortran-4.2 to compile.
> My environment is:
> NETCDFHOME /usr/local/netcdf-
> CC mpicc
> FC mpif90
> F90 mpif90
> F77 mpif90
> CXX mpiCC
> CFLAGS '-O3 -fPIC -xHost -ip -no-prec-div -static-intel'
> CXXFLAGS '-O3 -fPIC -xHost -ip -no-prec-div -static-intel'
> FFLAGS '-O3 -fPIC -xHost -ip -no-prec-div -static-intel'
> CPP 'icc -E'
> CXXCPP 'icpc -E'
> CPPFLAGS '-I/usr/local/netcdf- 
> -I/usr/local/hdf5-1.8.9_intel_12/include -I/usr/local/zlib-1.2.7_intel_12'
> LDFLAGS '-L/usr/local/netcdf- 
> -L/usr/local/hdf5-1.8.9_intel_12/lib 
> -L/usr/local/zlib-1.2.7_intel_12'http://svn.unidata.ucar.edu/repos/netcdf-fortran/trunk/
> /usr/local/netcdf-$LD_LIBRARY_PATH
> setenv LIBS '-lnetcdf -lhdf5_hl -lhdf5 -lz'
> setenv LDLIBS '-lnetcdf -lhdf5_hl -lhdf5 -lz'
> My configure is:
> configure --prefix=/usr/local/netcdf- --enable-shared 
> --enable-static --enable-parallel-tests
> 'make' completes with no errors.
> A 'make check' fails at this point:
> ...
> libtool: link: mpif90 -I../fortran -I../f90 -O3 -fPIC -xHost -ip -no-prec-div 
> -static-intel -o .libs/nf_test test_get.o test_put.o nf_error.o nf_test.o 
> test_read.o test_write.o util.o fortlib.o  
> -L/usr/local/netcdf- -L/usr/local/hdf5-1.8.9_intel_12/lib 
> -L/usr/local/zlib-1.2.7_intel_12 ../fortran/.libs/libnetcdff.so 
> -L/usr/local/zlib-1.2.7/lib 
> /usr/local/netcdf- 
> /usr/local/hdf5-1.8.9_intel_12/lib/libhdf5_hl.so 
> /usr/local/hdf5-1.8.9_intel_12/lib/libhdf5.so -lrt -lm -lz -Wl,-rpath 
> -Wl,/usr/local/netcdf- -Wl,-rpath 
> -Wl,/usr/local/hdf5-1.8.9_intel_12/lib
> test_get.o: In function `test_nf_get_var1_text_':
> test_get.F:(.text+0x31): undefined reference to `nf_open_'
> test_get.F:(.text+0x108): undefined reference to `nf_get_var1_text_'
> test_get.F:(.text+0x148): undefined reference to `nf_get_var1_text_'
> test_get.F:(.text+0x1e0): undefined reference to `nf_get_var1_text_'
> test_get.F:(.text+0x2f8): undefined reference to `nf_get_var1_text_'
> test_get.F:(.text+0x365): undefined reference to `nf_close_'
> ...etc...
> A 'nm fortran/.libs/libnetcdff.a | grep nf_open' shows:
> 0000000000000250 T nf_open__
> 0000000000000130 T nf_open_par__
> U nf_open_
> U nf_open_par_
> What am I doing wrong?

I'm not sure, but have two suggestions to try:

  1.  Add -DgFortran to your CPPFLAGS and run configure again
  2.  If that doesn't work, try our current netcdf-fortran test release at


which uses the standard F03 C-interoperability mechanisms to call C functions
from Fortran, so doesn't need the underbar or double-underbar name mangling
stuff currently in cfortran.h that only works for certain C and Fortran compiler
combinations.  If you try approach 2, you'll have to run

  autoreconf -i

first to generate a configure script, which may entail installing the autoconf
package, if you don't already have it.

If one of these works, please let us know.


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

Ticket Details
Ticket ID: YTJ-181465
Department: Support netCDF
Priority: Normal
Status: Closed

NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.