Re: [netcdfgroup] Building NetCDF 4.1.3 with two different compilers

  • To: Mary Haley <haley@xxxxxxxx>
  • Subject: Re: [netcdfgroup] Building NetCDF 4.1.3 with two different compilers
  • From: Larry Baker <baker@xxxxxxxx>
  • Date: Tue, 6 Dec 2011 13:16:45 -0800
Mary,

There should be a compiler option that controls whether and how many 
underscores get added to external names by the compiler.  It sounds like the 
default for that option has changed on you.  I am not at work, so I cannot 
check what my gcc says about it.  But, you should be able to easily find the 
option.  Try gcc --help -v and gfortran --help -v.

Larry Baker
US Geological Survey
650-329-5608
baker@xxxxxxxx




On Dec 6, 2011, at 10:42 AM, Mary Haley wrote:

> 
> I'm running into an oddity when building NetCDF 4.1.3 on the same Linux 
> system, but with different versions of gcc and gfortran (4.1.2 versus 4.4.4). 
> 
> When I use 4.1.2, I don't get a second underscore after Fortran routine 
> names, when the Fortran routine name already has an underscore.  When I use 
> 4.4.4, I get this second underscore, which causes an undefined reference when 
> linking NetCDF with another package.
> 
> I need to know how I can make sure that second underscore doesn't get 
> appended?
> 
> --------------------------------------------------------------------------------------------------
> 
> For gcc/gfortran 4.1.2, I'm using the following settings:
> 
> setenv CPPFLAGS 
> '-I/glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/include 
> -I/glade/proj2/ncldev/install/mirage/external/include'
> setenv LDFLAGS '-L/glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/lib 
> -L/glade/proj2/ncldev/install/mirage/external/lib'
> 
> setenv FC gfortran
> setenv F77 gfortran
> setenv F90 gfortran
> setenv CC gcc
> setenv CXX g++
> 
> setenv CFLAGS -fPIC
> setenv FFLAGS '-fPIC -fno-second-underscore'
> setenv F90FLAGS '-fPIC -fno-second-underscore'
> setenv FCFLAGS '-fPIC -fno-second-underscore'
> setenv CXXFLAGS -fPIC
> 
> make clean
> make distclean
> 
> ./configure --disable-netcdf-4 --disable-dap --enable-f90 --disable-shared 
> --prefix=/glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf
> 
> make all install
> make install
> 
> and I get what I'd expect:
> 
> % nm /glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/lib/libnetcdff.a | 
> grep nf_inq_libvers
> 0000000000000333 T nf_inq_libvers_
>                 U nf_inq_libvers_
> 
> Note there's only one underscore after "nf_inq_libvers" in both cases.
> 
> --------------------------------------------------------------------------------------------------
> For gcc/gfortran 4.4.4, I only change the following settings:
> 
> setenv FC gfortran44
> setenv F77 gfortran44
> setenv F90 gfortran44
> setenv CC gcc44
> setenv CXX g++44
> 
> I then get:
> 
> % nm /glade/proj2/ncldev/install/mirage/netcdf-4.1.3-esmf/lib/libnetcdff.a | 
> grep nf_inq_libvers
> 0000000000000301 T nf_inq_libvers__
>                 U nf_inq_libvers_
> 
> Note the second underscore in one case, but not the other.
> 
> --------------------------------------------------------------------------------------------------
> 
> Is there some code I can modify to make sure that second underscore doesn't 
> get added?
> 
> Thanks,
> 
> --Mary
> 
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe,  visit: 
> http://www.unidata.ucar.edu/mailing_lists/ 



  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: