Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I would like to use the R packages RNetCDF and ncdf in Ubuntu.

When I try install.packages('RNetCDF') or install.packages('ncdf'), I get similar errors:

...
ncdf.c:3:20: fatal error: netcdf.h: No such file or directory
compilation terminated.
make: *** [ncdf.o] Error 1
ERROR: compilation failed for package ‘ncdf’
...
Warning message:
In install.packages("ncdf") :
  installation of package ‘ncdf’ had non-zero exit status

The packages libnetcdf6 and netcdf-bin from the Ubuntu repository are installed. Do I need to do something else?

share|improve this question
3  
you need to install the -dev of those packages to get the headers that are required to compile the package. – Justin Jul 3 '12 at 21:51
    
@Justin thanks. the only additional package required for ncdf was libnetcdf-dev – Abe Jul 3 '12 at 21:54
    
for RNetCDF, udunits-bin and libudunits2-dev are also required – Abe Jul 3 '12 at 21:58

2 Answers 2

up vote 8 down vote accepted

You need to install the -dev of those packages to get the headers that are required to compile the package. In this case, you need libnetcdf-dev, udunits-bin and libudunits2-dev

share|improve this answer

In my case, libudunits2-dev package was needed.

sudo apt-get install libudunits2-dev

Since I installed NetCDF from source, I had to manually specify the locations of lib and include folders

install.packages("/home/user/Downloads/RNetCDF_1.6.1-2.tar.gz", 
repos = NULL,
type="source",
dependencies=FALSE,
configure.args="--with-netcdf-include=/usr/local/netcdf-4.2.1-build/include --with-netcdf-lib=/usr/local/netcdf-4.2.1-build/lib")
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.