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.
> > Hi, > > It seems that the problem mentioned at: > > http://www.unidata.ucar.edu/software/netcdf/docs/known_symptoms.html#NF_INT_IS_C > > is not limited to the intel compiler. I had the same problem with > gfortran/gcc version 4.2.2 on an x86_64 system. > This is a well-tested combination, so you should be able to do this no problem. > I'm building with: > > CC=/local/bin/gcc > FC=/local/bin/gfortran > F77=/local/bin/gfortran > F90= > CFLAGS=-fPIC -Df2cFortran > FFLAGS=-fPIC > F90FLAGS=-fPIC > CXXFLAGS=-fPIC > CXX=/home/local/gcc/bin/g++ Don't bother setting F90 or F77, just set FC=gfortran. (It would be best to put local/bin in your path instead of using it as part of the compiler name, but I think it should still work.) Set CXX='' to stop the C++ API build and test. Don't set -fPIC anywhere. Instead, use --enable-shared in the configure file. It will set the correct options for your compilers (which probably will end up being -fPIC, but may also involve other stuff). Don't set f2cFortran in CPPFLAGS. Just let configure try to figure out what to set. As I recall, it depends on your version of gfortran - they changed their default name mangling around version 4.2. > > ./configure --enable-netcdf-4 --disable-f90 --with-hdf5=/home/local/opt --with-zlib=/home/local/opt --with-szlib=/home/local/opt Did you really mean to disable F90? If this is for ncl, and you only use the C API, you could just do --disable-f77 --disable-cxx, and build just the C API (and utilities and examples). Then you can forget this fortran stuff! ;-) > > I've attached the output from configure, make, and config.log. > > Note the problems with "g++". Does this affect the "fortran" part of > the build? I tried building with --disable-cxx, but it then tried to > use "c++". I don't need the C++ interface. Let's solve the fortran first, and if you want C++, we'll do that next. It's completely separate. But you will need a 64-bit capable version of c++. In fact, it should be part of your gcc package, and so if your gcc is 64-bit , then so is c++, unless you have some funny problem for your sysadmin to sort out. The symptom of your problem is here: checking for Fortran "byte"... yes checking for Fortran "integer*2"... yes checking if Fortran "byte" is C "signed char"... no checking if Fortran "byte" is C "short"... no checking if Fortran "byte" is C "int"... no checking if Fortran "byte" is C "long"... no checking if Fortran "integer*2" is C "short"... no checking if Fortran "integer*2" is C "int"... no checking if Fortran "integer*2" is C "long"... no checking if Fortran "integer" is C "int"... no checking if Fortran "integer" is C "long"... no checking if Fortran "real" is C "float"... no checking if Fortran "real" is C "double"... no checking if Fortran "doubleprecision" is C "double"... no checking if Fortran "doubleprecision" is C "float"... no These cannot all be "no"! Looking in config.log, I see: configure:24070: /local/bin/gcc -c -fPIC -Df2cFortran conftest.c conftest.c: In function 'sub_': conftest.c:4: warning: incompatible implicit declaration of built-in function 'exit' configure:24073: $? = 0 configure:24076: /local/bin/gfortran -fPIC -c conftestf.f configure:24079: $? = 0 configure:24082: /local/bin/gfortran -o conftest -fPIC conftestf.o conftest.o configure:24085: $? = 0 configure:24088: ./conftest ./conftest: error while loading shared libraries: libgfortran.so.2: wrong ELF class: ELFCLASS32 So there are two problems. The second is caused because libgfortran.so.2 is the 32-bit version. Do you have to provide the -m64 option to gfortran? I don't know (but set it in FCFLAGS and FFLAGS if you want to try it). But I seem to recall I had to find the 64-bit version of libgfortran and set my LD_LIBRARY_PATH to include that directory. (Or set LDFLAGS, but you will need to do that for every fortran program you build with netcdf, whereas LD_LIBRARY_FLAGS works for everything.) The first problem, concerning the exit function, might be because you have specified -fPIC. So try it again, with just CC and FC set, using --enable-shared, and let me know if it still doesn't work. Thanks, Ed Ticket Details =================== Ticket ID: XNR-979092 Department: Support netCDF Priority: Normal Status: Closed