[R] NetCDF within R: installation assistance

Ken Schmidt Ken.Schmidt at noaa.gov
Tue Dec 23 21:23:54 CET 2008

Greetings.  I am attempting to add NetCDF libraries within R, and have 
failed.  We have R version 2.8, and are running on a 64-bit Redhat Linux 
2.6.18 kernel:

Red Hat Enterprise Linux Client release 5.2 (Tikanga)
Linux halfmoon.ncdc.noaa.gov 2.6.18-92.1.22.el5 #1 SMP Fri Dec 5 
09:28:22 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

I have run the installation instructions found at 
"http://www.image.ucar.edu/Software/Netcdf/", but not successfully.  I'm 
wondering if you can give some advice that will change our outcome?

We've run "R CMD INSTALL 
-with-netcdf_libdir=/usr/local/netcdf-3.6.1/lib" ncdf_1.6.tar.gz" 
against NetCDF 3.6.1, 3.6.2, and 4.0 all with the same results.
I think our being on a 64-bit Linux has to do with the failure.  Can you 
confirm this?

Outputs are below from the 64-bit system "halfmoon":

[root at halfmoon local]# R --version
R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License version 2.
For more information about these matters see

Here is my output:

[root at halfmoon local]# R CMD INSTALL 
-with-netcdf_libdir=/usr/local/netcdf-3.6.1/lib" ncdf_1.6.tar.gz
* Installing to library '/usr/local/lib64/R/library'
* Installing *source* package 'ncdf' ...
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking /usr/local/netcdf-3.6.1/include/netcdf.h usability... yes
checking /usr/local/netcdf-3.6.1/include/netcdf.h presence... yes
checking for /usr/local/netcdf-3.6.1/include/netcdf.h... yes
Using user-specified netCDF include dir=/usr/local/netcdf-3.6.1/include
Found netcdf.h in: /usr/local/netcdf-3.6.1/include
checking for /usr/local/netcdf-3.6.1/lib/libnetcdf.a... yes
Using user-specified netCDF library dir=/usr/local/netcdf-3.6.1/lib
Found netcdf library file libnetcdf.a in directory 
configure: creating ./config.status
config.status: creating R/load.R
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/local/lib64/R/include 
-I/usr/local/netcdf-3.6.1/include -I/usr/local/include    -fpic  -g -O2 
-c ncdf2.c -o ncdf2.o
gcc -std=gnu99 -I/usr/local/lib64/R/include 
-I/usr/local/netcdf-3.6.1/include -I/usr/local/include    -fpic  -g -O2 
-c ncdf3.c -o ncdf3.o
ncdf3.c: In function 'R_nc_get_vara_charvarid':
ncdf3.c:221: warning: assignment discards qualifiers from pointer target 
ncdf3.c: In function 'R_nc_get_vara_numvarid':
ncdf3.c:267: warning: assignment discards qualifiers from pointer target 
gcc -std=gnu99 -I/usr/local/lib64/R/include 
-I/usr/local/netcdf-3.6.1/include -I/usr/local/include    -fpic  -g -O2 
-c ncdf.c -o ncdf.o
ncdf.c: In function 'R_nc_ttc_to_nctype':
ncdf.c:424: warning: implicit declaration of function 'exit'
ncdf.c:424: warning: incompatible implicit declaration of built-in 
function 'exit'
gcc -std=gnu99 -shared -L/usr/local/lib64 -o ncdf.so ncdf2.o ncdf3.o 
ncdf.o -L/usr/local/netcdf-3.6.1/lib -lnetcdf
/usr/bin/ld: /usr/local/netcdf-3.6.1/lib/libnetcdf.a(attr.o): relocation 
R_X86_64_32 against `a local symbol' can not be used when making a 
shared object; recompile with -fPIC
/usr/local/netcdf-3.6.1/lib/libnetcdf.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [ncdf.so] Error 1
chmod: cannot access `/usr/local/lib64/R/library/ncdf/libs/*': No such 
file or directory
ERROR: compilation failed for package 'ncdf'
** Removing '/usr/local/lib64/R/library/ncdf'

Thanks in advance,

Ken Schmidt
National Climatic Data Center
Asheville, NC 28801

More information about the R-help mailing list