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

[netCDF #SDC-125933]: Make Check Test Fail -- Told to report to you.



Sigourney,

> Thank you, that fixed my build problem. If I may ask, what is the
> difference between using -I, -L and -l when doing this?

Here's what they mean for Unix systems:

The -I flag is for "Include directory", and tells the compiler where to look for
header files or Fortran module files, both of which define interfaces of 
functions
as well as definitions of types and global constants or parameters.  The -I flag
is almost always followed by a directory path that ends with "/include".  It is 
only
used by the compiler for compiling source code, but has no meaning to the 
linker.
The kinds of files in an include directory are *.h and *.mod files.

The -L flag is for "Library directory", and tells the linker or loader where to 
look
for binary (compiled) libraries, such as libnetcdf.a or libnetcdf.o.  The -L 
flag
is almost always followed by a directory path that ends with "/lib".  It is only
used by the linker or loader, or the compiler acting as a linker/loader, but has
no meaning or relevance to the compilation of source code into .o object files.
The kinds of files in a library directory are lib*.a and lib*.so files.

The -l flag is for "library name", and specifies which libraries to search in 
which
order for compiled functions and global constants.  Using "-lfoo" specifies to
look for library files such as libfoo.a (a static archive library), libfoo.so 
(a shared
object library), or libfoo.so.N or libfoo.so.N.M, where N and M encode versions
and compatibility characteristics of libraries, so multiple versions of the same
library can be stored in the same directory.

The order of multiple -I flags is important, specifying which order to search 
for
header files in include directories, in case the same header files with the same
name occur in multiple directories.  Similarly, the order of multiple -L flags 
and 
-l flags is important, specifying the order of search for functions in various 
libraries.
There is no significance to the order of a -I flag and a -L or -l flag, as the 
-I flags
are used in the compile step, but the -L or -l flags are used in the link step.

Typically, for large software packages, compiling sources into objects is done 
in
multiple compile steps, which have -I flags but no -L or -l flags.  Then the .o 
object files and libraries are linked together in a link step that has no -I 
flags
but may have lots of -L or -l flags.

> I think this may be causing my larger problem. I'm trying to compile a
> model and I'm getting an error about the netcdf
> 
> Undefined symbols for architecture x86_64:
> "___netcdf_MOD_nf90_close", referenced from:
> ___ice_forcing_MOD_ocn_data_ncar_init_3d in ice_forcing.o
> ___ice_forcing_MOD_ocn_data_ncar_init in ice_forcing.o
> 
> There's quite a few errors after this referencing other mods in other files
> but they all start with netcdf. I'm under the impression that what you just
> helped me through was me building netcdf fortran for 64 bit (the -m64 flags
> I set). But this error seems to be contradicting that...unless it's a
> linking issue with -I, -L or -l?

"x86_64" is a 64-bit architecture and is consistent with the "-m64" flags you
specified when compiling.  The undefined symbol errors may indicate missing
-L flags specifying where compiled Fortran modules are found or could indicate
use of a different Fortran compiler or flags than were used when a module file
or library was compiled into a binary object.  This is confusing, because .mod 
files are like .h files in that they specify interfaces, but they are also like 
.o files
in that they are compiled and different Fortran compilers use different formats
for .mod files.

I can't tell from the error messages which is the case for the model you are 
trying
to link with the Fortran netCDF library, but make sure the .o files are being 
linked
with "-lnetcdff" (the Fortran library) preceding "-lnetcdf" (the C library) if 
you are
using static rather than shared libraries.  Also check out the guidance given 
under
the "Linking your programs with netCDF Fortran libraries" section of the 
document
"Building the netCDF-4.2 and later Fortran libraries" at

  http://www.unidata.ucar.edu/netcdf/docs/netcdf-fortran-install.html

--Russ

> Sorry if this is out of your jurisdiction of help!
> And thank you so much!
> Sigourney Stelma
> 
> 
> address@hidden> wrote:
> 
> > Aha, it looks like you should have used "-L" instead of "-I" in LDFLAGS:
> >
> > > setenv LDFLAGS -I/usr/local/netcdf/lib
> >   setenv LDFLAGS -L/usr/local/netcdf/lib
> >
> > See if that doesn't fix the problem ...
> >
> > --Russ
> >
> > > Yes sorry, that was a copy/paste error. To be sure, I tried it again and
> > > still the same error.
> > > Attached is the config.log for the failed netcdf fortran run. The netcdf
> > c
> > > library should be 4.3.0, I just installed it today and it said the build
> > > was successful.
> > >
> > > I have gcc and gfortran installed. Here's the entire output but you're
> > > probably looking for the versions? Both are 4.5
> > >
> > > [new-host:local/netcdf/include] sastelma% gcc -v
> > > Using built-in specs.
> > > COLLECT_GCC=gcc
> > >
> > COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.5.4/lto-wrapper
> > > Target: x86_64-apple-darwin12
> > > Configured with: ../gcc-4.5.4/configure --prefix=/opt/local
> > > --build=x86_64-apple-darwin12
> > > --enable-languages=c,c++,objc,obj-c++,fortran,java
> > > --libdir=/opt/local/lib/gcc45 --includedir=/opt/local/include/gcc45
> > > --infodir=/opt/local/share/info --mandir=/opt/local/share/man
> > > --datarootdir=/opt/local/share/gcc-4.5 --with-local-prefix=/opt/local
> > > --with-libiconv-prefix=/opt/local --with-system-zlib --disable-nls
> > > --program-suffix=-mp-4.5
> > > --with-gxx-include-dir=/opt/local/include/gcc45/c++/
> > --with-gmp=/opt/local
> > > --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local
> > > --enable-stage1-checking --disable-multilib --with-as=/opt/local/bin/as
> > > --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=
> > > https://trac.macports.org/newticket --enable-lto
> > > --with-pkgversion='MacPorts gcc45 4.5.4_6'
> > > Thread model: posix
> > > gcc version 4.5.4 (MacPorts gcc45 4.5.4_6)
> > >
> > > [new-host:local/netcdf/include] sastelma% gfortran -v
> > > Using built-in specs.
> > > COLLECT_GCC=gfortran
> > >
> > COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.5.4/lto-wrapper
> > > Target: x86_64-apple-darwin12
> > > Configured with: ../gcc-4.5.4/configure --prefix=/opt/local
> > > --build=x86_64-apple-darwin12
> > > --enable-languages=c,c++,objc,obj-c++,fortran,java
> > > --libdir=/opt/local/lib/gcc45 --includedir=/opt/local/include/gcc45
> > > --infodir=/opt/local/share/info --mandir=/opt/local/share/man
> > > --datarootdir=/opt/local/share/gcc-4.5 --with-local-prefix=/opt/local
> > > --with-libiconv-prefix=/opt/local --with-system-zlib --disable-nls
> > > --program-suffix=-mp-4.5
> > > --with-gxx-include-dir=/opt/local/include/gcc45/c++/
> > --with-gmp=/opt/local
> > > --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local
> > > --enable-stage1-checking --disable-multilib --with-as=/opt/local/bin/as
> > > --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=
> > > https://trac.macports.org/newticket --enable-lto
> > > --with-pkgversion='MacPorts gcc45 4.5.4_6'
> > > Thread model: posix
> > > gcc version 4.5.4 (MacPorts gcc45 4.5.4_6)
> > >
> > > Thank you!
> > > Sigourney Stelma
> > >
> > >
> > > address@hidden> wrote:
> > >
> > > > Sigourney
> > > >
> > > > > That did not work. I got the same exact error as in my previous
> > email.
> > > > > Here's what I'm putting into the terminal:
> > > > >
> > > > > setenv CC gcc
> > > > > setenv CFLAGS -m64
> > > > > setenv CXX g++
> > > > > setenv CXXFLAGS -m64
> > > > > setenv FC gfortran
> > > > > setenv FCFLAGS -m64
> > > > > setenv FFLAGS -m64
> > > > > setenv F77 gfortran
> > > > > FC gfortran
> > > > > setenv YLD_LIBRARY_PATH /usr/local/netcdf/lib
> > > >
> > > > Was the above a copy-and-paste error?  You should have used
> > > >
> > > >   setenv DYLD_LIBRARY_PATH /usr/local/netcdf/lib
> > > >
> > > > > setenv CPPFLAGS -I/usr/local/netcdf/include
> > > > > setenv LDFLAGS -I/usr/local/netcdf/lib
> > > > > ./configure --prefix=/usr/local/netcdf
> > > >
> > > > Please send us your config.log file for the failed Fortran build,
> > > > and also the version of the netCDF C library you installed under
> > > > /usr/local/netcdf.
> > > >
> > > > Also, what is the output from
> > > >
> > > >   $ gcc --version
> > > >   $ gfortran --version
> > > >
> > > > Another way to get gfortran installed on a Mac OSX platform is
> > > > to use the macports.org package management system, with:
> > > >
> > > >   $ port netcdf-fortran
> > > >
> > > > --Russ
> > > >
> > > > > Thanks!
> > > > > Sigourney
> > > > >
> > > > >
> > > > > address@hidden> wrote:
> > > > >
> > > > > > Hi Sigourney,
> > > > > >
> > > > > > > I'm trying to build netcdf fortran with gfortran. I got an error
> > > > during
> > > > > > the
> > > > > > > 'make check' stage of my build and it told me to contact you.
> > Here's
> > > > the
> > > > > > > error:
> > > > > > >
> > > > > > > dyld: Symbol not found: _ncerr
> > > > > > > Referenced from:
> > > > > > >
> > > > > >
> > > >
> > /Users/sastelma/downloads/netcdf-fortran-4.2/fortran/.libs/libnetcdff.5.dylib
> > > > > > > Expected in: flat namespace
> > > > > > > in
> > > > > > >
> > > > > >
> > > >
> > /Users/sastelma/downloads/netcdf-fortran-4.2/fortran/.libs/libnetcdff.5.dylib
> > > > > > > /bin/sh: line 1: 51512 Trace/BPT trap: 5       ${dir}$tst
> > > > > > > FAIL: nf_test
> > > > > > >
> > > > > > > *** Copying file with fill values.
> > > > > > > *** SUCCESS!
> > > > > > > PASS: create_fills.sh
> > > > > > > dyld: Symbol not found: _ncerr
> > > > > > > Referenced from:
> > > > > > >
> > > > > >
> > > >
> > /Users/sastelma/downloads/netcdf-fortran-4.2/fortran/.libs/libnetcdff.5.dylib
> > > > > > > Expected in: flat namespace
> > > > > > > in
> > > > > > >
> > > > > >
> > > >
> > /Users/sastelma/downloads/netcdf-fortran-4.2/fortran/.libs/libnetcdff.5.dylib
> > > > > > > /bin/sh: line 1: 51537 Trace/BPT trap: 5       ${dir}$tst
> > > > > > > FAIL: tst_f90
> > > > > > > ================================================
> > > > > > > 2 of 3 tests failed
> > > > > > > Please report to address@hidden
> > > > > > > ================================================
> > > > > > >
> > > > > > > I'm not sure at all how to fix this issue.
> > > > > >
> > > > > > I assume you're following the build instructions here:
> > > > > >
> > > > > >
> > http://www.unidata.ucar.edu/netcdf/docs/netcdf-fortran-install.html
> > > > > >
> > > > > > and that you're building on a Mac OSX platform, using shared
> > libraries.
> > > > > >
> > > > > > Did you set the environment variable DYLD_LIBRARY_PATH to contain
> > the
> > > > > > library directory where the netCDF C library is installed, as
> > mentioned
> > > > > > in step 3 of the build instructions under "Using shared
> > libraries"?  If
> > > > > > not, please try again with that environment variable set and let us
> > > > know
> > > > > > if that doesn't fix the problem.
> > > > > >
> > > > > > --Russ
> > > > > >
> > > > > > > Thank you,
> > > > > > > Sigourney Stelma
> > > > > > >
> > > > > > >
> > > > > > Russ Rew                                         UCAR Unidata
> > Program
> > > > > > address@hidden
> > http://www.unidata.ucar.edu
> > > > > >
> > > > > >
> > > > > >
> > > > > > Ticket Details
> > > > > > ===================
> > > > > > Ticket ID: SDC-125933
> > > > > > Department: Support netCDF
> > > > > > Priority: Normal
> > > > > > Status: Closed
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > Russ Rew                                         UCAR Unidata Program
> > > > address@hidden                      http://www.unidata.ucar.edu
> > > >
> > > >
> > > >
> > > > Ticket Details
> > > > ===================
> > > > Ticket ID: SDC-125933
> > > > Department: Support netCDF
> > > > Priority: Normal
> > > > Status: Closed
> > > >
> > > >
> > >
> > >
> >
> > Russ Rew                                         UCAR Unidata Program
> > address@hidden                      http://www.unidata.ucar.edu
> >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: SDC-125933
> > Department: Support netCDF
> > Priority: Normal
> > Status: Closed
> >
> >
> 
> 
Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: SDC-125933
Department: Support netCDF
Priority: Normal
Status: Closed