2013-06-10 12 views
5

Tôi đang cố gắng để cài đặt r gói ncdf trên một máy chủ Ubuntu 10.04:Lắp đặt gói ncdf thất bại do thiếu tiêu đề mặc dù nó có

install.packages("ncdf", type = "source") 
Installing package into ‘/home/me/R/x86_64-pc-linux-gnu-library/3.0’ 
(as ‘lib’ is unspecified) 
trying URL 'http://cran.rstudio.com/src/contrib/ncdf_1.6.6.tar.gz' 
Content type 'application/x-gzip' length 79403 bytes (77 Kb) 
opened URL 
================================================== 
downloaded 77 Kb 

* installing *source* package ‘ncdf’ ... 
** package ‘ncdf’ successfully unpacked and MD5 sums checked 
checking for nc-config... no 
checking for gcc... gcc -std=gnu99 
checking whether the C compiler works... yes 
checking for C compiler default output file name... a.out 
checking for suffix of executables... 
checking whether we are cross compiling... no 
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 ISO C89... none needed 
checking how to run the C preprocessor... gcc -std=gnu99 -E 
checking for grep that handles long lines and -e... /bin/grep 
checking for egrep... /bin/grep -E 
checking for ANSI C header files... no 
checking for sys/types.h... no 
checking for sys/stat.h... no 
checking for stdlib.h... no 
checking for string.h... no 
checking for memory.h... no 
checking for strings.h... no 
checking for inttypes.h... no 
checking for stdint.h... no 
checking for unistd.h... no 
checking netcdf.h usability... no 
checking netcdf.h presence... no 
checking for netcdf.h... no 
configure: error: netcdf header netcdf.h not found 
ERROR: configuration failed for package ‘ncdf’ 
* removing ‘/home/me/R/x86_64-pc-linux-gnu-library/3.0/ncdf’ 
Warning in install.packages : 
    installation of package ‘ncdf’ had non-zero exit status 

Tôi cũng tải về các gói nguồn và cố gắng để cài đặt trong vỏ, nhưng có kết quả tương tự.

wget http://cran.r-project.org/src/contrib/ncdf_1.6.6.tar.gz 
R CMD INSTALL ncdf_1.6.6.tar.gz 

Rõ ràng, trình cài đặt không tìm thấy tệp tiêu đề chính xác. Vì vậy, tôi đã tìm kiếm các tập tin bằng tay và tìm thấy nó:

[email protected]:/usr/include# ls -ahl netcdf.h 
-rw-r--r-- 1 root root 30K 2009-12-22 04:47 netcdf.h 

Gói netcdf-bin, netcdf-dbg, netcdf-doc, libnetcdf-devlibnetcdf4 được cài đặt tất cả đúng cách. apt-get đã được cập nhật. Đây là thông tin phiên của tôi:

R version 3.0.1 (2013-05-16) 
Platform: x86_64-pc-linux-gnu (64-bit) 

locale: 
[1] C 

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

loaded via a namespace (and not attached): 
[1] tools_3.0.1 

Làm cách nào để thuyết phục trình cài đặt R sử dụng tệp tiêu đề nằm dưới /usr/include?

Trả lời

7

Bạn cần xem kịch bản configure.in để xem chính xác những gì nó kiểm tra. Có thể nó đang mong đợi netcdf.h trong thư mục con thay vì trực tiếp trong /usr/include.

Tôi nghĩ rằng tôi đã tạo điều này trong quá khứ. Tôi có thể xem lại sau.

+7

Cảm ơn bạn rất nhiều! Có tệp 'configure.ac' trong gói ncdf. Tôi không phải là một {linux, C,/bin/make/sense} -ninja nhưng tôi đã tìm thấy đối số '--with-netcdf-include' trong đó. Vì vậy, 'install.packages (" ncdf ", type =" source ", configure.args =" - with-netcdf-include =/usr/include ")' làm mọi thứ hoạt động. – Beasterfield

+0

Có, 'configure --help' phải luôn là bước đầu tiên của bạn và nó sẽ cho bạn biết. Odd, mặc dù, rằng họ không nhìn ở đó theo mặc định. –

1

Nếu không có nguồn tải xuống, bạn chỉ cần đặt một số biến môi trường. Đối với tôi, đây là

export NETCDF_INCLUDE=/usr/include 

Sau khi thực hiện việc này, install.packages("ncdf") đã hoạt động.

Điều này được mô tả trong tệp INSTALL.

+0

Đọc 5 phút đôi khi có thể giúp bạn tiết kiệm 5 giờ thử. Cảm ơn. – Beasterfield

+0

Lô hàng này có thể giúp bạn tiết kiệm thêm vài giây: 'NETCDF_INCLUDE =/usr/include Rscript -e 'install.packages (" ncdf ")'' – Jealie