This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> 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: ClosedAttachment:
test.nc4
Description: Binary data