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

Re: 20010608: Finding the libnetcdf library



>To: address@hidden
>From: "Klein, Jim" <address@hidden>
>Subject: Finding the libnetcdf library
>Organization: UCAR/Unidata
>Keywords: 200106081815.f58IFjp10675

Hi Jim,

> HELP!
> 
> We have installed netcdf (latest version) on our SUN. We can only
> find libnetcdf.a and libnetcdf_c++.a but the documentation specifies
> libnetcdf as the library to link. We are trying to compile and link
> a small test program created with ncgen after a dump using ncdump.
> 
> All our work is in fortran using f77
> 
> What do you think the problem might be? We have tried linking with
> the files in the lib directory but we get a list of unresolved
> external netcdf commands as a linker error message.

You're probably just using the wrong compiler option syntax for
specifying the library and where to get it.  If you installed in
"/local/netcdf", for example, then the libraries would have been
installed in the directory /local/netcdf/lib/ (as libnetcdf.a and
libnetcdf_c++).  So in this case a Fortran-77 program that used the
libnetcdf.a library, say prog.f, could be compiled and linked with
something like:

 f77 -I/local/netcdf/include prog.f -L/local/netcdf/lib -lnetcdf -o prog

in a single step, or if you separate the compile and link steps, with
something like:

 f77 -I/upc/netcdf/include -c prog.f
 f77 prog.o -L/upc/netcdf/lib -lnetcdf -o prog

In either case, you use the "-L" flag to specify which directory to look
for the libraries in and the "-l" flag to specify which libraries to
use.  The argument to the "-l" parameter gets "lib" pre-pended and
".a" appended to it by the linker or compiler to construct the actual
file name of the library.

--Russ

_____________________________________________________________________

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