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

[netCDF #WEP-155858]: NetCDF 4.2 Fortran on Ubuntu 12.10 (Intended to be used with ROMS ocean model)



Alexis,

> Unfortunately, the FCFLAGS="-fPIC" did not modify the error message!

Hmm, that's unexpected.

> This is what I did:
> 
> 0) sudo make uninstall for both C and Fortran libraries.
> 
> 1) Set flags, configure, make and install for the C libraries.
> Everything seemed to have gone fine. The output of the
> configure,make,check and install steps are attached with the "C2" suffix:
> CFLAGS=-fPIC
> CPPFLAGS=-I/usr/local/include
> LDFLAGS=-L/usr/local/lib
> sudo ./configure --prefix=/usr/local
> sudo make
> sudo make check
> sudo make install
> 
> 2) Set flags, configure and make for the Fortran libraries, but the same
> error appeared as you can see from the log_make and log_check files for
> the fortran attempt:
> CFLAGS=-fPIC
> FCFLAGS=-fPIC
> CC=gcc
> FC=gfortran
> F77=gfortran
> CPPFLAGS=-I/usr/local/include
> LDFLAGS=-L/usr/local/lib
> sudo ./configure --prefix=/usr/local
> sudo make
> sudo make check
> (The install step was not done as the error appeared first)

I have two suggestions.  First, don't run "./configure", "make all",
or "make check" using sudo, because on some systems that prevents
inheritance of environment variable settings, as a security
precaution.  The only command you need to run with "sudo" is "make
install" (or possibly "make clean" if you've previously run as root).

Second, make sure you run "make clean" before running "./configure",
to ensure the new FLAGS settings get applied to all the compile steps.
I noticed in the log_make_FORTRAN2 file you attached, some of the
objects were not recompiled, for example:

  Making all in f90
  make[2]: Entering directory 
`/home/espinosa/ROMS/NetCDF/netcdf-fortran-4.2/f90'
  make  all-am
  make[3]: Entering directory 
`/home/espinosa/ROMS/NetCDF/netcdf-fortran-4.2/f90'
  make[3]: Nothing to be done for `all-am'.
  make[3]: Leaving directory `/home/espinosa/ROMS/NetCDF/netcdf-fortran-4.2/f90'

When the files in that directory get recompiled, you should expect to
see:

  /bin/sh ../libtool --tag=FC   --mode=compile gfortran  -fPIC -c -o netcdf4.lo 
 netcdf4.f90
  libtool: compile:  gfortran -fPIC -c netcdf4.f90  -fPIC -o .libs/netcdf4.o

with "-fPIC" used.  That is the specific object that the error message
is about in

  /usr/bin/ld: ../f90/.libs/libnetcdff90.a(netcdf.o): relocation R_X86_64_32 
against   `.rodata.str1.8' can not be used when making a shared object; 
recompile with -fPIC

so it's important that it gets recompiled with -fPIC.

> The log_make_FORTRAN2 shows that the -fPIC option is being used for a
> lot of intermediate compiling steps, but that is still not enought for
> solving the problem.
> 
> Any suggestions?

If the suggestions above don't work, I don't know why it's failing.  Next week a
staff member who has been at the EGU meeting in Vienna will return, and he might
be able to duplicate and debug the problem on an Ubuntu virtual machine to which
he has access ...

--Russ

> Thank you very much for your help and interest,
> Alexis Espinosa
> 
> On 4/12/2013 1:02 AM, Unidata netCDF Support wrote:
> > Hi Alexis,
> >
> >> I'm trying to install netcdf-4.2 (fortran version) in my Ubuntu 12.10
> >> (Quantal) system. I have tried some suggestions available on the ROMS
> >> forum but those explanations were for Ubuntu 12.04 and for cygwin and a
> >> subtle difference may be creating the problem I'm finding: I can't pass
> >> the check correctly.
> >>
> >> So, I went directly to your page and found the "Building the netCDF-4.2
> >> and later Fortran libraries" explanation and followed it carefully, but
> >> it is still not working.
> >>
> >> 0. The first thing I found is that you suggest to install first the C
> >> library in shared mode. So I "make uninstall" the failed fortran and C
> >> succesful installations (which were first tried to be installed in
> >> --disable-shared mode)
> >>
> >> 1. Then I installed the C version again like this:
> >> sudo ./configure --prefix=/usr/local --enable-netcdf-4 --enable-dap
> >> (I kept the ROMS' forum suggestions except the --disable-shared option)
> >> sudo make
> >> sudo make check
> >> sudo make install
> >> (everything went fine. I'm attaching you the output of the
> >> sudo make check > log_check_C 2>&1
> >> command)
> >>
> >> 2. Then I tried the installation of the Fortran library
> >> CC=gcc
> >> FC=gfortran
> >> CPPFLAGS=-I/usr/local/include
> >> LDFLAGS=-L/usr/local/include/lib
> >> sudo ./configure --prefix=/usr/local
> >> sudo make
> >> sudo make check
> >> (But the make and make check failed. I'm attaching you the output of:
> >> sudo make > log_make_FORTRAN 2>&1
> >> and
> >> sudo make check > log_check_FORTRAN 2>&1
> >> commands)
> >>
> >> QUESTION: What should I do in order to install the fortran library
> >> correctly?
> > The error message you are getting
> >
> >    /usr/bin/ld: ../f90/.libs/libnetcdff90.a(netcdf.o): relocation 
> > R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared 
> > object; recompile with -fPIC
> >
> > indicates that you need to add "-fPIC" the the compiler options for 
> > gfortran when configuring
> > the netCDF Fortran library.  It may also be necessary to add -fPIC to the 
> > gcc options when
> > configuring the netCDF C library.
> >
> > Sometimes -fPIC is needed for 64-bit shared libraries but not for 32-bit 
> > shared libraries.  I
> > thought libtool was supposed to figure this out and provide the Position 
> > Independent Code
> > option automatically when needed, but it doesn't seem always do that when 
> > needed.
> >
> > Please try configuring and building the netCDF C library with 
> > CFLAGS="-fPIC" and then
> > installing it again.  Then try configuring and building the netCDF Fortran 
> > library
> > with FCFLAGS="-fPIC".  If "make check" doesn't work after that, please let 
> > us know.
> > We don't have an Ubuntu platform configured on which to test the netCDF 
> > Fortran build,
> > so we'd also like to know if this succeeds, in which case we'll add to the 
> > instructions.
> >
> > Thanks for reporting the problem!
> >
> > --Russ
> >
> >> Thanks a lot,
> >> Alexis Espinosa
> >> PD I previously installed a lot of supposed dependencies:
> >> sudo apt-get install -y cdbs debhelper gcc gfortran libcunit1-dev
> >> libcurl4-gnutls-dev libdap-dev libhdf5-dev texinfo texlive-base
> >> texlive-latex-base zlib1g-dev make build-essential bison doxygen curl
> >> g++ libmpich2-dev subversion
> >>
> >>
> >>
> >>
> >> --
> >> Alexis Espinosa Gayosso
> >> PhD Candidate
> >> School of Environmental Systems Engineering and The UWA Oceans Institute
> >> The University of Western Australia
> >> MO15, 35 Stirling Highway
> >> Crawley, WA 6009
> >> Australia
> >>
> >> Tel: (+618) 6488-7359
> >> Fax: (+618) 6488-1015
> >> Email: address@hidden
> >> Web: www2.sese.uwa.edu.au/~espinosa/
> >>
> >>
> >>
> > Russ Rew                                         UCAR Unidata Program
> > address@hidden                      http://www.unidata.ucar.edu
> >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: WEP-155858
> > Department: Support netCDF
> > Priority: Normal
> > Status: Closed
> >
> >
> 
> 
> --
> Alexis Espinosa Gayosso
> PhD Candidate
> School of Environmental Systems Engineering and The UWA Oceans Institute
> The University of Western Australia
> MO15, 35 Stirling Highway
> Crawley, WA 6009
> Australia
> 
> Tel: (+618) 6488-7359
> Fax: (+618) 6488-1015
> Email: address@hidden
> Web: www2.sese.uwa.edu.au/~espinosa/
> 
> 
> 
Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: WEP-155858
Department: Support netCDF
Priority: Normal
Status: Closed