2012-07-03 96 views
7

我想在Ubuntu中使用R包RNetCDF和ncdf。如何在Ubuntu上安裝R軟件包「RNetCDF」和「ncdf」?

當我嘗試install.packages('RNetCDF')或,我得到類似的錯誤:

... 
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 

的包從Ubuntu庫libnetcdf6netcdf-bin安裝。我需要做其他事嗎?

+3

您需要安裝這些軟件包的'-dev'來獲取編譯軟件包所需的頭文件。 – Justin

+1

@Justin謝謝。 'ncdf'所需的唯一附加軟件包是libNetcdf-dev' – Abe

+1

for'RNetCDF','udunits-bin'和'libudunits2-dev'也是必需的 – Abe

回答

13

您需要安裝這些軟件包的-dev以獲取編譯軟件包所需的標頭。在這種情況下,您需要libnetcdf-devudunits-binlibudunits2-dev

+0

爲了安裝ncdf4軟件包(對ncdf軟件包的更新),我還需要運行'sudo apt-get install netcdf-bin' – avianattackarmada

6

在我的情況下,需要libudunits2-dev軟件包。

sudo apt-get install libudunits2-dev

自從我從源代碼安裝的NetCDF,我不得不手動指定LIB的位置包括文件夾

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") 
0

只是爲了澄清,因爲您最初的問題被設定爲R ,並且修復應用在R之外。我最初試圖做

install.packages(「libnetcdf-dev」),它不起作用。

相反,來自R之外:命令和apt-get安裝libnetcdf-dev的

問題解決了我。