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 >cc: "Janke" <address@hidden> >From: Geoff Quelch <address@hidden> >Subject: Errors with netCDF compilation with gcc 3.0.2 >Organization: Computational Geosciences Inc. >Keywords: 200203072100.g27L0KK13330 Hi Geoff, > I am having an problem compiling the netCDF 3.5.0 library with gcc 3.0.2. > > The error occurs here: > > make[2]: Entering directory `/usr/local/src/netcdf-3.5.0/src/libsrc' > /usr/local/bin/gcc -c -O -I. -DNDEBUG attr.c > /usr/local/bin/gcc -c -O -I. -DNDEBUG dim.c > /usr/local/bin/gcc -c -O -I. -DNDEBUG error.c > /usr/local/bin/gcc -c -O -I. -DNDEBUG -DVERSION=`cat ../VERSION` libvers.c > /usr/local/bin/gcc -c -O -I. -DNDEBUG nc.c > /usr/local/bin/gcc -c -O -I. -DNDEBUG ncio.c > /usr/local/bin/gcc -c -O -I. -DNDEBUG ncx.c > ncx.c:200:2: #error "ix_short implementation" > ncx.c:204: parse error before "ix_short" > ncx.c: In function `get_ix_short': > > etc. > > I have the following environment variables set: > > CC=/usr/local/bin/gcc > CXX=/usr/local/bin/g++ > LD_LIBRARY_PATH=/usr/local/lib/ > > Kernel: Linux hydro 2.2.19-6.2.1smp > > Is this a kernel update issue? The online documents do not indicate a > required kernel for this version of gcc or netCDF. The gcc 3.0.2 built > without issues on this system. This is not a kernel issue. It looks as if the standard include file <limits.h> is not defining the standard macro SHRT_MAX, which is supposed to be defined as the maximum value of type short, typically 32767. You could verify this by trying to compile and running this simple C program: #include <limits.h> int main(int argc, char* argv[]) { printf("SHRT_MAX = %ld\n", (long)SHRT_MAX); printf("INT_MAX = %ld\n", (long)INT_MAX); printf("LONG_MAX = %ld\n", LONG_MAX); return 0; } If this doesn't compile, you'll need to fix your gcc configuration. If this compiles and runs OK, then you'll need to figure out what makes the following not compile, perhaps an incorrect definition of one of the macros SHRT_MAX, INT_MAX, or LONG_MAX in the <limits.h> file, which should be installed in /usr/inlude/limits.h: #include <limits.h> #define X_SHORT_MAX 32767 #define SHORT_MAX SHRT_MAX #if SHORT_MAX == X_SHORT_MAX typedef short ix_short; #define SIZEOF_IX_SHORT SIZEOF_SHORT #define IX_SHORT_MAX SHORT_MAX #elif INT_MAX >= X_SHORT_MAX typedef int ix_short; #define SIZEOF_IX_SHORT SIZEOF_INT #define IX_SHORT_MAX INT_MAX #elif LONG_MAX >= X_SHORT_MAX typedef long ix_short; #define SIZEOF_IX_SHORT SIZEOF_LONG #define IX_SHORT_MAX LONG_MAX #else #error "ix_short implementation" #endif The C interface compiles fine on my platform with gcc 3.0, but g++ complains about a few of the "friend" declarations, which have been fixed in netcdf 3.5.1 (for example changing "friend NcFile" to "friend class NcFile"). --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu