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

[netCDF #MLU-486882]: NetCDF must be built with netCDF-4 enabled



Rakia,

> Finally (and with the help of a very kind and patient colleague) I have 
> managed to get beyond the netCDF installation issues. I first downloaded and 
> installed the 'netCDF C library and utilities, version 4.2.1.1'. I then 
> downloaded & installed zlib. I then downloaded hdf5 and installed it with
> 
> ./configure --with-zlib=DIR
> 
> and make and make install. For some reason, the hdf5 files were installed in 
> a weird place, so I copied them to /usr/local.

Although it has nothing to do with the question you ask below, you should
make and make install the netcdf-4.2.1.1 library *after* the hdf5 library is
installed, because the netCDF-4 library requires the hdf5 library, and behaves
as if you had used the configure option --disable-netcdf-4 if the configure
script for netcdf doesn't find the hdf5 library.  Perhaps it worked because
the hdf5 library had been previously installed somewhere where the netcdf 
configure script could find it ...  

But if "make check" for the netcdf library worked, maybe it doesn't matter
that you did the unneeded step of installing the hdf5 library after the
netcdf library.

> I then set
> export CPPFLAGS="-I /usr/local/netcdf/include"
> export  DYLDFLAGS="-L /usr/local/netcdf/lib"
> export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
> 
> and running ./configure in the netCDFcxx4 directory worked so I could then 
> move on to make and make install.

I'm happy to hear you got that working.

> Running g++ -o simple_xy_wr simple_xy_wr.cpp -I/usr/local/netcdf/cxx4/ 
> -L/usr/local/lib now produces
> 
> simple_xy_wr.cpp: In function ‘int main()’:
> simple_xy_wr.cpp:51: error: ‘class netCDF::NcFile’ has no member named 
> ‘is_valid’
> simple_xy_wr.cpp:64: error: ‘class netCDF::NcFile’ has no member named 
> ‘add_dim’
> simple_xy_wr.cpp:65: error: ‘class netCDF::NcFile’ has no member named 
> ‘add_dim’
> simple_xy_wr.cpp:69: error: ‘class netCDF::NcFile’ has no member named 
> ‘add_var’
> 
> so I guess the good news is that my installation worked, but for some reason, 
> writing the file simple_xy_wr does not work.

There are two very different versions of the netcdf C++ library, as explained 
here:

  http://www.unidata.ucar.edu/downloads/netcdf/netcdf-cxx/

You have built the netCDF-4 version 4.2 of the C++ library.  However the 
examples
you found, such as the C++ examples available from this page

  http://www.unidata.ucar.edu/netcdf/examples/programs/

are for the legacy NetCDF-3 C++ library.  We should make this distinction clear 
on
that examples page, so thanks for pointing out the problem.

The documentation for these two C++ programming interfaces is different also:

   http://www.unidata.ucar.edu/netcdf/docs/netcdf-cxx.html
   http://www.unidata.ucar.edu/netcdf/docs/cxx4/

The first few paragraphs of each document explains why there are two 
incompatible versions and what some of the differences are.

So far no one has written examples for the netCDF-4 C++ interface that 
correspond
to the netCDF-3 C++ examples you're trying to compile and run.  However, there 
are instructive examples for the netCDF-4 C++ interface here:

  http://www.unidata.ucar.edu/netcdf/docs/cxx4/examples.html

You should be able to compile and link those examples, which show how to use the
new netCDF-4 C++ library.

--Russ

> From: Unidata netCDF Support [address@hidden]
> Sent: 20 February 2013 18:10
> To: Rakia Meister
> Cc: address@hidden
> Subject: [netCDF #MLU-486882]: NetCDF must be built with netCDF-4 enabled
> 
> Rakia,
> 
> > As far as I'm aware, I have installed netCDF-4 without using the 
> > --disable-netcdf-4 option. However, I did not have HDF5 installed. I have 
> > now downloaded zlib-1.2.5. Running ./configure, make and make install ran 
> > without an error for zlib. I have also downloaded hdf5-1.8.6, and again, 
> > ./configure, make and make install did not produce any errors.
> >
> > I then tried to configure netcdf-cxx4-4.2 again, but I get the same error 
> > about netCDF-4 not being enabled. ...
> 
> The required order of installation is zlib, then hdf5, then netcdf-4, then 
> netcdf-cxx4.
> It sounds like you missed rebuilding and reinstalling netcdf-4 after you 
> installed
> hdf5.  This order is required, because the configure script for netcdf-4 
> looks for
> an installed hdf5 library and behaves as if "--disable-netcdf-4" had been 
> specified
> if it doesn't find one.  Sorry, I should have said earlier that netCDF-4 will 
> be
> installed without support for netCDF-4/HDF5 files if the HDF5 library is not 
> installed
> or if it can't find it, regardless of whether you've specified 
> "--disable-netcdf-4".
> 
> > ...  When I run 'ncdump -k test.nc' I get an error saying -bash: ncdump: 
> > command not found. So I guess netcdf is not installed.
> 
> That's a different problem.  From what you said before, the ncdump was 
> installed
> in /usr/local/netcdf/bin/ncdump, so you would have either had to add that 
> directory
> to your PATH for bash to find it, or you would have had to invoke it with the 
> full
> path, as in:
> 
> /usr/local/netcdf/bin/ncdump -k test.nc
> 
> If you need more details about rebuilding and reinstalling netcdf-4 after 
> installing
> hdf5, see the instructions here:
> 
> http://www.unidata.ucar.edu/netcdf/docs/build_default.html
> 
> --Russ
> 
> ______________________________________
> > From: Unidata netCDF Support [address@hidden]
> > Sent: 19 February 2013 23:55
> > To: Rakia Meister
> > Cc: address@hidden
> > Subject: [netCDF #MLU-486882]: NetCDF must be built with netCDF-4 enabled
> >
> > > Brilliant, thanks, first problem overcome. I now DON'T get the 'netcdf.h 
> > > file could not be found' error anymore. The solution was to export the 
> > > environment variables. It now says
> > >
> > > configure:3667: gcc  -I /usr/local/netcdf/include  conftest.c  >&5
> > >
> > > In the configure.log file.
> > >
> > > I am now back to the "NetCDF must be built with netCDF-4 enabled" error. 
> > > I did set
> > >
> > > DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/usr/local/lib
> > >
> > > and
> > >
> > > export DYLD_LIBRARY_PATH
> > >
> > > and
> > >
> > > DYLDFLAGS="-L /usr/local/netcdf/lib"
> > >
> > > and
> > >
> > > export DYLDFLAGS
> > >
> > > but to no avail. Configure.log file is attached. ...
> >
> > I guess I should have asked earlier if you have installed netCDF-4, without
> > using the --disable-netcdf-4 option.  To install netCDF-4 you would have
> > had to install hdf5 first, because netCDF-4 depends on it.  To determine
> > whether you have netCDF-4 installed, try running ncdump on the attached 
> > binary
> > file:
> >
> > ncdump -k test.nc
> >
> > and verify that the output is
> >
> > netCDF-4 classic model
> >
> > If instead you get
> >
> > test.nc4: NetCDF: Unknown file format
> >
> > then you haven't installed netCDF-4, which is required for the netcdf-cxx4
> > software that depends on the C library for netCDF-4.
> >
> > --Russ
> >
> > >
> > > ________________________________________
> > > From: Unidata netCDF Support [address@hidden]
> > > Sent: 19 February 2013 20:49
> > > To: Rakia Meister
> > > Cc: address@hidden
> > > Subject: [netCDF #MLU-486882]: NetCDF must be built with netCDF-4 enabled
> > >
> > > Rakia,
> > >
> > > > Thanks a million for your reply!
> > > >
> > > > Unfortunately, I now don't even get as far as the netCDF-4 problem! I 
> > > > have set
> > > >
> > > > CPPFLAGS="-I /usr/local/netcdf/include"
> > > >
> > > > which worked fine yesterday, but today I get the error
> > > >
> > > > "configure: error: netcdf.h could not be found. Please set CPPFLAGS.".
> > >
> > > Your CPPFLAGS isn't getting passed into the configure script, because its 
> > > compile
> > > line (in config.log) is
> > >
> > > configure:15660: gcc -c -g -O2  conftest.c >&5
> > >
> > > instead of
> > >
> > > configure:15660: gcc -c -g -O2 -I /usr/local/include conftest.c >&5
> > >
> > > I suspect either you're using a shell that uses a different syntax for 
> > > setting
> > > environment variables (for example csh uses "setenv CPPFLAGS ..." or 
> > > you're not
> > > exporting the environment variable after you set it, as in
> > >
> > > CPPFLAGS="-I /usr/local/netcdf/include"
> > > export CPPFLAGS
> > >
> > > or just
> > >
> > > export CPPFLAGS="-I /usr/local/netcdf/include"
> > >
> > > You can also use the environment variables as just arguments to the 
> > > configure
> > > script, as in:
> > >
> > > ./configure CPPFLAGS="-I /usr/local/netcdf/include" LDFLAGS=...
> > >
> > > If it still won't work, another possibility is installing netCDF from one 
> > > of
> > > the package management systems, such as fink or MacPorts.
> > >
> > > --Russ
> > >
> > > > I know it's there however, I've found netcdf.h on the terminal in 
> > > > usr/local/netcdf/include/. So I'm really not sure what's going on. (I 
> > > > also set
> > > >
> > > > DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/usr/local/lib and
> > > >
> > > > export DYLD_LIBRARY_PATH and
> > > >
> > > > DYLDFLAGS="-L /usr/local/netcdf/lib"
> > > >
> > > > but obviously that doesn't help if for some reason the CPPFLAG is not 
> > > > set...).
> > > >
> > > > I downloaded the NetCDF-4 C++ Source Code by the way.
> > > >
> > > > Many thanks for your help!
> > > >
> > > > Rakia
> > > >
> > > >
> > > > ________________________________________
> > > > From: Unidata netCDF Support [address@hidden]
> > > > Sent: 19 February 2013 17:42
> > > > To: Rakia Meister
> > > > Cc: address@hidden
> > > > Subject: [netCDF #MLU-486882]: NetCDF must be built with netCDF-4 
> > > > enabled
> > > >
> > > > Hi Rakia,
> > > >
> > > > > I would like to convert netCDF files to Ascii using C++ as described 
> > > > > here:
> > > > >
> > > > > http://www.unidata.ucar.edu/software/netcdf/examples/programs/
> > > > >
> > > > > I have downloaded the netCDF C++ source code from here:
> > > > >
> > > > > http://www.unidata.ucar.edu/downloads/netcdf/netcdf-cxx/index.jsp
> > > >
> > > > Which of the two netCDF C++ distributions did you download?  One is 
> > > > labelled
> > > > "NetCDF-4 C++ Source Code" and the other "Legacy NetCDF-3 C++ Source 
> > > > Code".
> > > > If you downloaded the first, it requires that the netCDF C library has 
> > > > already
> > > > been built and installed somewhere (for example in lib/, bin/, and 
> > > > include/
> > > > subdirectories under /usr/local).  The second "legacy C++" API is 
> > > > adequate for
> > > > reading and writing netCDF-3 files, which are still the majority of 
> > > > netCDF data.
> > > > But it still requires that the netCDF-3 library is installed first.
> > > >
> > > > > and encounter a problem when configuring.
> > > > >
> > > > > I have set CPPFLAGS="-I /usr/local/netcdf/include" and LDFLAGS="-L
> > > > > /usr/local/netcdf/lib". When I then run ./configure, I get the error
> > > > > message "NetCDF must be built with netCDF-4 enabled". I found another
> > > > > couple of threads where the same problem is mentioned, so I also
> > > > > set "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib" and "export
> > > > > LD_LIBRARY_PATH", however, the same error message keeps appearing.
> > > >
> > > > I think for MacOS-X, you need to set DYLD_LIBRARY_PATH instead of
> > > > LD_LIBRARY_PATH.
> > > >
> > > > Please let us know if this helps.
> > > >
> > > > --Russ
> > > >
> > > > Russ Rew                                         UCAR Unidata Program
> > > > address@hidden                      http://www.unidata.ucar.edu
> > > >
> > > >
> > > >
> > > > Ticket Details
> > > > ===================
> > > > Ticket ID: MLU-486882
> > > > Department: Support netCDF
> > > > Priority: Normal
> > > > Status: Closed
> > > >
> > > >
> > > >
> > > Russ Rew                                         UCAR Unidata Program
> > > address@hidden                      http://www.unidata.ucar.edu
> > >
> > >
> > >
> > > Ticket Details
> > > ===================
> > > Ticket ID: MLU-486882
> > > Department: Support netCDF
> > > Priority: Normal
> > > Status: Closed
> > >
> > >
> > >
> > Russ Rew                                         UCAR Unidata Program
> > address@hidden                      http://www.unidata.ucar.edu
> >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: MLU-486882
> > Department: Support netCDF
> > Priority: Normal
> > Status: Closed
> >
> >
> Russ Rew                                         UCAR Unidata Program
> address@hidden                      http://www.unidata.ucar.edu
> 
> 
> 
> Ticket Details
> ===================
> Ticket ID: MLU-486882
> Department: Support netCDF
> Priority: Normal
> Status: Closed
> 
> 
> 
Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: MLU-486882
Department: Support netCDF
Priority: Normal
Status: Closed