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.
>To: address@hidden >From: Hein Zelle <address@hidden> >Subject: netcdf library, gcc-3.2.1 >Organization: UCAR/Unidata >Keywords: 200301132154.h0DLs1x06322 Hi, > I would like to report that I managed to compile the NetCDF library > (3.5.0) using linux and gcc-3.2.1. I am not sure if anyone else had > success with this sofar, but I would like to tell you what I had to do > to get it to work, so you can include it in a next version. > > options to build: > > CPPFLAGS=-Df2cFortran > CXXFLAGS=-Wno-deprecated > CXX=g++ > > I had to set the -Wno-deprecated flags because netcdf uses the old C++ > header files (like <iostream.h>) instead of the new ones > (<iostream>). This may not be required, but it saves a lot of long > warning messages. Yes, thanks. The C++ interface is updated in the 3.5.1-beta10 version, available from: ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-beta.tar.Z I've tested this with the 3.2 versions of gcc/g++/g77 and it seems to work OK now. > I had to modify the configure script to accept and detect my g++ > compiler: it found an error trying to compile the test program. In the > test program > > #line 1230 "configure" > #include "confdefs.h" > //#ifdef __cplusplus > //extern "C" void exit(int); > //#endif > > #include <iostream.h> > int main() { > cout << ""; > return 0; > } > > I had to comment out the line "extern "C" void exit(int);", because > g++ was complaining about a different kind of exception being thrown > by in the declaration and implementation of exit(). Without that line > it worked fine, but it may be better to actually fix the code. Why is > that line included anyway? Good question. It's unfortunately generated automatically by the old version of autoconf we used to generate the configure script from a "configure.in" file. Before releasing this version, I would like to update it to use the current autoconf/automake/libtool packages, so we don't have problems like this. > Finally I had to change a few things in > > netcdf.cpp, lines 157, 360, 391: > change > friend NcFile; > to > friend class NcFile; > > ncvalues.cpp, lines 307, 319 > change > long save=os.flags(); > to > std::_Ios_Fmtflags save = os.flags(); > > > After these changes the library compiles without errors or warnings, > and passes all the tests in 'make test', especially the C++ ones. > If you would like to have a copy of my modified version, let me know > and I will send it to you. If it's convenient, I would appreciate you trying the netcdf-beta version referenced above, to make sure it works OK on your platform. I recently tried it with version 3.3 of gcc/g77/g++ on Mac OS X, and found I needed CFLAGS=-no-cpp-precomp in addition: CC=/usr/local/bin/gcc CPPFLAGS=-Df2cFortran CFLAGS=-no-cpp-precomp FC=/usr/local/bin/g77 CXX=/usr/local/bin/g++ --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu