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

Re: 20010202: HELP with netcdf.hh on redhat g++



>To: address@hidden
>From: Roshan Ram <address@hidden>
>Subject: HELP with netcdf.hh on redhat g++ 
>Organization: UCAR/Unidata
>Keywords: 200102020525.f125PkX08093

Hi Roshan,

>  While trying to complile example.cc with g++ (Red Hat Linux Release
> 7.0), this is what i see.
>  
> In file included from netcdf.hh:17:
>               from example.cc:3:
> ncvalues.hh:33: 'NC_INT' was not declared in this
> scope
> ncvalues.hh:33: enumeratot value for 'ncInt' not an
> integer constant
> ncvalues.hh:40: 'NC_FILL_BYTE' was not declared in
> this scope
> ncvalues.hh:41: 'NC_FILL_CHAR' was not declared in
> this scope
> ncvalues.hh:42: 'NC_FILL_SHORT' was not declared in
> this scope
> ncvalues.hh:44: 'NC_FILL_INT' was not declared in this
> scope
> ncvalues.hh:46: 'NC_FILL_FLOAT' was not declared in
> this scope
> ncvalues.hh:47: 'NC_FILL_DOUBLE' was not declared in
> this scope
> example.cc:63: name lookup of 'i' changed for new ISO
> 'for' scoping
> example.cc:58: using obsolete binding at 'i'
> 
> 
> What can i do? 
> I'm kinda new to both unix and c++, so not sure how to
> debug this.
> but have tons of netcdf data thats awaiting analysis.
>  HELP.

The file example.cc #includes the header file "ncvalues.hh" from the
same directory, which #includes the file <netcdf.h> where constants
such as "NC_INT" and "NC_FILL_BYTE" are defined.  In order for the g++
compiler to find the netcdf.h header file, it has to be told which
directory to look in.  This depends on whether you have already
installed the netCDF library yet.  If you haven't installed the
library, you need to use the "-Idirectory" option of g++ to tell it
that the netcdf.h file is in the directory "../libsrc", as in:

  g++ -I../libsrc example.cc ...

but if you have installed netcdf, you need to tell g++ to look where
the netdf.h file is installed, as in

  g++ -I/local/netcdf/include example.cc ...

To link with the netCDF library, you will have to do something similar
to tell g++ where to find the library using the -Ldirectory option and
the -llibrary option, as in

  g++ -I../libsrc example.cc -L../libsrc -lnetcdf -o example

if you haven't installed netCDF or

  g++ -I../libsrc example.cc -L/local/netcdf/lib -lnetcdf -o example

if you have installed it in /local/netcdf/.

--Russ

_____________________________________________________________________

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