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

20020520: netCDF g77 compilation and "-fno-second-underscore"



Tao,

> To: <address@hidden>
> cc: "Bob Holt" <address@hidden>,
> cc: "Brent Chapin" <address@hidden>
> From: "Tao" <address@hidden>
> Subject: help wanted to compile netcdf library with g77
> Organization: UCAR/Unidata
> Keywords: 200205172158.g4HLwZa14895

The above message contained the following:

> Dear Sir:
> 
> We are trying to compile the netcdf library from the source code. The =
> system we are running is=20
> Linux 2.4.7-10 and compiler g77, cc, and c++. We don't have Fortran 90 =
> compiler available.=20
> We followed the installation instruction and the compilation is failed =
> by the undefined=20
> reference error shown when we do "make test" ("make" doesn't show us any =
> error).=20
> However, If we set the environment FFLAGS=3D-fno-underscoring before we =
> run ./configure then
> we will be able to pass "make test" successfully. The problem is that =
> our original codes that
> call the function in netcdf library have to be compiled using g77 with =
> the option -fno-second-underscore due to
> the other fortran library we are using.

Interesting problem.

It sounds like the author of the other Fortran library that you're using
decided to not follow well-established naming conventions for your
system. I would complain to them.

See below.

> So if we use -fno-underscoring =
> when we compile netcdf library using g77,=20
> we will get undefined reference error pointing to the netcdf functions =
> when we use -fno-second-underscore=20
> to compile our own code.=20
> 
> By the way, setting FFLAGS to -fno-second-underscore while we compile =
> netcdf library will
> also fail when we run "make test".
> 
> 
> Our question here is "do we have to add the option -fno-underscoring =
> when we compile netcdf library using g77?"
> If we don't have to, would you please give us some hint to get around =
> this problem?
> 
> Thank your for your time and have a good weekend!
> 
> Tao
...
> As follows is A-G based on your requirement on the web site. We didn't =
> set FFLAGS=3D-fno-underscoring here so get lots
> of complains in test.log from "make test"
> 
> A. uname -a
> Linux localhost.localdomain 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 =
> unknown
> 
> B. VERSION
> 3.5.0
> 
> C. The absolute pathnames of all compilers (C, Fortran, C++) used in the =
> build process=20
> g77     /usr/bin
> cc      /usr/bin
> c++    /usr/bin
...
> D. configure.log from step 6 "./configure"
> 
> creating cache ./config.cache
> checking for top-level source-directory
> /home/txu/software/netcdf-3.5.0/src
> checking for m4 preprocessor
> checking for m4... m4
> checking m4 flags... -B10000
> checking C compiler "/usr/bin/cc"... works
> checking how to make dependencies... false
> checking for CC... no
> checking for cxx... no
> checking for c++... c++
> checking C++ compiler "c++"... works
> checking how to run the C preprocessor... /usr/bin/cc -E
> checking user-defined Fortran-77 compiler "/usr/bin/g77"... works
> checking for Fortran .F compiler...=20
> checking if Fortran-77 compiler handles *.F files... yes
> checking user-defined Fortran-90 compiler ""... failed to compile test =
> program
> configure: warning: The Fortran-90 interface will not be built
> checking for nm utility
> checking for nm... nm
> checking nm flags...=20
> checking for C-equivalent to Fortran routine "SUB"... sub_
> checking for Fortran "byte"... yes
> checking for Fortran "integer*2"... yes
> checking if Fortran "byte" is C "signed char"... yes
> 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"... yes
> 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"... yes
> checking if Fortran "real" is C "float"... yes
> checking if Fortran "doubleprecision" is C "double"... yes
> checking for Fortran-equivalent to netCDF "byte"... byte
> checking for Fortran-equivalent to netCDF "short"... integer*2
> checking for math library
> checking for tanh in -lc... no
> checking for tanh in -lm... yes
> checking for ar utility
> checking for ar... ar
> checking ar flags... cru
> checking for nm utility
> checking for nm... (cached) nm
> checking nm flags...=20
> checking for ranlib... ranlib
> checking for stdlib.h... yes
> checking for sys/types.h... yes
> checking for strerror... yes
> checking for working ftruncate()... yes
> checking for working alloca.h... yes
> checking for alloca... yes
> checking for st_blksize in struct stat... yes
> checking for IEEE floating point format... yes
> checking for ANSI C header files... yes
> checking for size_t... yes
> checking for off_t... yes
> checking for ssize_t... yes
> checking for ptrdiff_t... yes
> checking for uchar... no
> checking whether char is unsigned... no
> checking whether byte ordering is bigendian... no
> checking size of short... 2
> checking size of int... 4
> checking size of long... 4
> checking size of float... 4
> checking size of double... 8
> checking size of off_t... 4
> checking size of size_t... 4
> checking for manual-page index command...=20
> checking binary distribution directory... =
> /home/ftp/pub/binary/dummy_system
> updating cache ./config.cache
> creating ./config.status
> creating macros.make
> udcreating fortran/nfconfig.inc
> creating libsrc/ncconfig.h
...
> Making `test' in directory /home/txu/software/netcdf-3.5.0/src/fortran
> 
> make[2]: Entering directory =
> `/home/txu/software/netcdf-3.5.0/src/fortran'
> + /usr/bin/g77 -c ftest.F
> ftest.F: In subroutine `tncacpy':
> ftest.F:187: warning:
>                call ncagt (outcdf, NCBYTE, attnam, bytval, iret)
>                     1
> ftest.F:196: (continued):
>                call ncagt (outcdf, NCGLOBAL, attnam, shval, iret)=20
>                     2
> Argument #4 of `ncagt' is one precision at (2) but is some other =
> precision at (1) [info -f g77 M GLOBALS]
> ftest.F:187: warning:
>                call ncagt (outcdf, NCBYTE, attnam, bytval, iret)
>                     1
> ftest.F:198: (continued):
>                call ncagt (outcdf, NCGLOBAL, attnam, lngval, iret)       =
>  =20
>                     2
> Argument #4 of `ncagt' is one precision at (2) but is some other =
> precision at (1) [info -f g77 M GLOBALS]
...

The above warning messages can be supressed by using the g77 option
"-Wno-globals".

> ar cru ../libsrc/libnetcdf.a fort-attio.o fort-control.o fort-dim.o =
> fort-genatt.o fort-geninq.o fort-genvar.o fort-lib.o fort-misc.o =
> fort-v2compat.o fort-vario.o fort-var1io.o fort-varaio.o fort-varmio.o =
> fort-varsio.o
> ranlib ../libsrc/libnetcdf.a
> /usr/bin/g77 -o ftest   ftest.o ../libsrc/libnetcdf.a=20
> ftest.o: In function `MAIN__':
> ftest.o(.text+0x15): undefined reference to `ncpopt_'
> ftest.o(.text+0x59): undefined reference to `nccre_'

Odd. Given the way your Fortran-77 netCDF interface was built:

> /usr/bin/cc -c -O -I../libsrc  -DNDEBUG fort-v2compat.c
...
> ar cru ../libsrc/libnetcdf.a fort-attio.o fort-control.o fort-dim.o =
> fort-genatt.o fort-geninq.o fort-genvar.o fort-lib.o fort-misc.o =
> fort-v2compat.o fort-vario.o fort-var1io.o fort-varaio.o fort-varmio.o =
> fort-varsio.o
> ranlib ../libsrc/libnetcdf.a

 I would have expected the global symbol "nccre_" to exist in the netCDF
library.

I'd like to know the "nccre"-contents that library.  Would you please 
send me the output from the following command:

    /usr/bin/nm -gA libsrc/libnetcdf.a | grep nccre

Regards,
Steve Emmerson   <http://www.unidata.ucar.edu>