Question

I have to use a recent version of gfortran and use netcdf. So I have to complie the netcdf libraries with this new version of gfortran, which is 4.8.2

Before configuration and installing of netcdf, I had to set the following environment variables:

#!/bin/bash

export CC="$HOME/gcc-trunk/bin/gcc"
export LDFLAGS="-L$HOME/gcc-trunk/lib -L$HOME/gcc-trunk/lib64"
export CPP="$HOME/gcc-trunk/bin/cpp"
export FC="$HOME/gcc-trunk/bin/gfortran"
export F77="$HOME/gcc-trunk/bin/gfortran -x f77"
export CXX="$HOME/gcc-trunk/bin/c++"
export CXXPP="$HOME/gcc-trunk/bin/cpp"

export LD_LIBRARY_PATH=$PWD/netcdf/lib:${LD_LIBRARY_PATH}

export CPPFLAGS="-DgFortran -cpp -I$PWD/netcdf/include"
export LDFLAGS="-L$PWD/netcdf/lib"

Everything goes ok when I run configure, but when I make "make check". I get the following error:

libtool: link: /home/antonio/gcc-trunk/bin/gfortran -x f77 -I../fortran -I../f90 -g -o .libs/nf_test test_get.o test_put.o nf_error.o nf_test.o test_read.o test_write.o util.o fortlib.o  -L/media/022f8e40-437e-4c37-a8b0-538c07b842a3/home/antonio/DATOS/seas_pred/Fortran_code/netcdf/netcdf-fortran-4.2/netcdf/lib ../fortran/.libs/libnetcdff.so -lnetcdf -rpath /media/022f8e40-437e-4c37-a8b0-538c07b842a3/home/antonio/DATOS/seas_pred/Fortran_code/netcdf/netcdf/lib
gfortran: error: unrecognized command line option '-rpath'
make[2]: *** [nf_test] Error 1
make[2]: se sale del directorio «/media/022f8e40-437e-4c37-a8b0-538c07b842a3/home/antonio/DATOS/seas_pred/Fortran_code/netcdf/netcdf-fortran-4.2/nf_test»
make[1]: *** [check-am] Error 2
make[1]: se sale del directorio «/media/022f8e40-437e-4c37-a8b0-538c07b842a3/home/antonio/DATOS/seas_pred/Fortran_code/netcdf/netcdf-fortran-4.2/nf_test»
make: *** [check-recursive] Error 1

It seems -rpath is an option to be passed to the linker, so it should add a -Wl, before, but it doesn't.

Perhaps I should add this option in an environmental variable, but don't know which.

Can anybody help?

Thanks a lot.

Was it helpful?

Solution 2

The problem was caused by the environmental variable F77.

It seems that configure, sets the appropriate values when this variable is not set, but get into trouble when we set it. I solved it deleting the line in the script that sets the F77 variable.

Thaks to everybody who tired to find a solution, specially to Sadiq Huq.

OTHER TIPS

I think you are compiling from the wrong directory. You have $PWD in the value field of LD_LIBRARY_PATH, CPPFLAGS & LDFLAGS. Easiest way to fix is to replace $PWD with the absolute path where your netcdf directory is located.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top