Skip to content

R CMD INSTALL cannot find netcdf library

4 messages · jiho, Simon Urbanek

#
Hi,

I tried to install RNetCDF binary package but when I try to load it  
after installation, it gives this message

	> library("RNetCDF")
	Error in dyn.load(x, as.logical(local), as.logical(now)) :
		unable to load shared library '/Library/Frameworks/R.framework/ 
Versions/2.3/Resources/library/RNetCDF/libs/ppc/RNetCDF.so':
	dlopen(/Library/Frameworks/R.framework/Versions/2.3/Resources/ 
library/RNetCDF/libs/ppc/RNetCDF.so, 6): Symbol not found: _nc_inq_dimid
	  Referenced from: /Library/Frameworks/R.framework/Versions/2.3/ 
Resources/library/RNetCDF/libs/ppc/RNetCDF.so
	  Expected in: flat namespace
	Error in library("RNetCDF") : .First.lib failed for 'RNetCDF'


So I tried to install it from source, through the interface (i.e.  
with default parameters). It issues the command:

	install.packages(c("RNetCDF"),lib="/Library/Frameworks/Resources/ 
library/",contriburl=contrib.url(getOption 
("repos"),"source"),type='source',dependencies=FALSE)

and the compilation stops because it cannot find netcdf libraries.  
These libraries are installed through fink and hence are in /sw/lib/  
and the headers in /sw/include/:

	jiho at ibook:RNetCDF$ ll /sw/lib/libnetcdf*
	lrwxr-xr-x   1 root  admin       29 Jul 18 14:59 /sw/lib/libnetcdf. 
3.5.0.dylib -> /sw/lib/libnetcdf.3.6.1.dylib
	-rwxr-xr-x   1 root  admin  1152056 Jul 18 14:59 /sw/lib/libnetcdf. 
3.6.1.dylib
	lrwxr-xr-x   1 root  admin       29 Jul 18 14:59 /sw/lib/libnetcdf. 
3.dylib -> /sw/lib/libnetcdf.3.6.1.dylib
	-rwxr-xr-x   1 root  admin   779952 Jul 18 14:59 /sw/lib/libnetcdf.a
	lrwxr-xr-x   1 root  admin       25 Jul 18 14:59 /sw/lib/ 
libnetcdf.dylib -> /sw/lib/libnetcdf.3.dylib
	-rw-r--r--   1 root  admin   131532 Jul 18 14:59 /sw/lib/libnetcdf_c+ 
+.3.6.1.dylib
	lrwxr-xr-x   1 root  admin       33 Jul 18 14:59 /sw/lib/libnetcdf_c+ 
+.3.dylib -> /sw/lib/libnetcdf_c++.3.6.1.dylib
	-rwxr-xr-x   1 root  admin   169032 Jul 18 14:59 /sw/lib/libnetcdf_c+ 
+.a
	lrwxr-xr-x   1 root  admin       29 Jul 18 14:59 /sw/lib/libnetcdf_c+ 
+.dylib -> /sw/lib/libnetcdf_c++.3.dylib

	jiho at ibook:RNetCDF$ ll /sw/include/netcdf*
	-rwxr-xr-x   1 root  admin   31574 Jul 18 14:59 /sw/include/netcdf.h
	-rwxr-xr-x   1 root  admin      23 Jul 18 14:59 /sw/include/netcdf.hh
	-rwxr-xr-x   1 root  admin   49501 Jul 18 14:59 /sw/include/netcdf.inc
	-rwxr-xr-x   1 root  admin  166532 Jul 18 14:59 /sw/include/netcdf.mod
	-rwxr-xr-x   1 root  admin   18793 Jul 18 14:59 /sw/include/netcdfcpp.h

But these are non-standard paths. So I looked at ./configure --help  
which gives me the options to set:

	  --with-netcdf-include=INCLUDE_PATH
	                          the location of netcdf header files
	  --with-netcdf-lib=LIB_PATH
	                          the location of netcdf libraries

Therefore I tried the command:

	install.packages(c("RNetCDF"),lib="/Library/Frameworks/Resources/ 
library/",contriburl=contrib.url(getOption 
("repos"),"source"),type='source',dependencies=FALSE,configure.args="--w 
ith-netcdf-include=/sw/include/ --with-netcdf-lib=/sw/lib/")

but to no avail, I still get the same error message:

	checking for main in -lnetcdf...
	The downloaded packages are in
		/private/tmp/RtmpakpDoj/downloaded_packages
	no
	configure: error: netcdf library not found
	ERROR: configuration failed for package 'RNetCDF'
	** Removing '/Library/Frameworks/Resources/library/RNetCDF'
	Warning message:
	installation of package 'RNetCDF' had non-zero exit status in:  
install.packages(c("RNetCDF"), lib = "/Library/Frameworks/Resources/ 
library/",


Does somebody know what I am doing wrong and what could be the  
solution (apart from installing netcdf libraries in classic system  
directories: I prefer them to be managed by Fink)? Thanks in advance.

JiHO
---
http://jo.irisson.free.fr/
#
Following up on my own e-mail:

there are in fact 2 problems with netcdf (and udunits by the way)  
librairies in /sw/

1/ compilation of source package: configure.args seems to be wrongly  
transferred to R CMD INSTALL from install.packages. Indeed:

	R CMD INSTALL --configure-args="--with-netcdf-include='/sw/inc' -- 
with-netcdf-lib='/sw/lib' --with-udunits-lib='/sw/lib/' --with- 
udunits-include='/sw/include'" RNetCDF_1.2-1.tar.gz

works from the command line while

	install.packages(c("RNetCDF"), lib = "/Library/Frameworks/ 
R.framework/Resources/library/", contriburl=contrib.url(getOption 
("repos"),"source"), type="source", dependencies=FALSE,  
configure.args=c("--with-netcdf-include='/sw/inc'","--with-netcdf- 
lib='/sw/lib'","--with-udunits-lib='/sw/lib/'","--with-udunits- 
include='/sw/include'"))

does not work from inside R shell.

2/ use of binary packages: the binary packages cannot find netcdf  
library and send an error messa	ge about Symbols not found.


Is there something I do wrong for 1? can I test something else to see  
if this is really a bug?
Concerning 2, is there a way to include Fink's path in R at startup?

Thanks in advance.

JiHO
---
http://jo.irisson.free.fr/
#
JiHO,
On Sep 5, 2006, at 4:42 AM, jiho wrote:

            
Thanks, I have fixed that now - the binary contained only i386  
version of netcdf. The mirrors should be updated soon, for the moment  
you can install it via

install.packages("RNetCDF",,"http://r.research.att.com")

(Note: you still need /usr/local/etc/udunits.dat same as with udunits  
package).
You actually discovered a bug in install.packages - unnamed configure  
arguments were not passed on. Thanks, this is now fixed in 2.4.0  
alpha and R-devel.

Cheers,
Simon
#
On 05 Sep 2006, at 20:47 , Simon Urbanek wrote:
Thanks for this. Actually I got ncdf and RNetCDF to compile by using  
directly R CMD INSTALL so I finally got the functionality I wanted  
(and managed to output some very nice graphics actually... ahhhh I  
love R plotting functions! ;-) )
So it seems, because it worked from R CMD INSTALL. Thank you for  
fixing this so fast.

Cheers,

JiHO
---
http://jo.irisson.free.fr/