[R] ncdf4 package installation in R

David Pierce dpierce at ucsd.edu
Tue Oct 26 20:22:50 CEST 2010

shaticus wrote:
> Hello all,
> I could use some help installing the ncdf4 package in R (under CentOS
> 5.4).
> When I issue an 'install.packages(c('ncdf4')) in R, compilation succeeds
> but
> I receive the following error during the loading phase of installation:
> ** building package indices ...
> Error in dyn.load(file, DLLpath = DLLpath, ...) :
>   unable to load shared object
> '/usr/local/lib64/R/library/ncdf4/libs/ncdf4.so':
>   libnetcdf.so.6: cannot open shared object file: No such file or
> directory
> ERROR: loading failed
> * removing â/usr/local/lib64/R/library/ncdf4â


R is not finding the netcdf library that you compiled and, presumably,
installed.  If you installed the netcdf library in a standard place, such
as /usr/local/lib, it would probably be found by default.  If you don't
want to (or can't) install in a standard location, the easiest fix is to
add the location where you installed the netcdf library to your
LD_LIBRARY_PATH environmental variable.  For example, if the netcdf libary
is in /opt/sw/netcdf/lib, then you'd add that directory to

Hope that helps,


David W. Pierce
Division of Climate, Atmospheric Science, and Physical Oceanography
Scripps Institution of Oceanography
(858) 534-8276 (voice)  /  (858) 534-8561 (fax)    dpierce at ucsd.edu

More information about the R-help mailing list