[R] need automake/autoconf help to build RnetCDF and ncdf packages

Adam Wilson adam.wilson at uconn.edu
Thu Mar 13 16:09:38 CET 2008


Greetings all,

I recently tried to install RNetCDF from within R (install.packages)
on Fedora Core 8 (with netcdf 3.6.2 and netcdf-devel 3.6.2 already
installed).  This resulted in an error because the netcdf header files
are installed in  /usr/include/netcdf-3 rather than /usr/include which
is where RNetCDF looks for them.  This problem was described in a 2006
post (see below), but no satisfactory resolution was posted.

For the benefit of Fedora users that run into this problem and search
the R-help archives, I am posting a  solution.  The command is
actually quite simple:

install.packages("RNetCDF",configure.args="--with-netcdf-include=/usr/include/netcdf-3")

If this does not work, check RnetCDF's configure.ac file for the line
that points to something like "/usr/include/..."  and change the
"netcdf-include" to the name of the new variable.  This will only be
necessary if the RNetCDF folks change the name of this variable (which
they did between the time of Paul's post below and yesterday).

As an aside, I've found netcdf extractions run much faster under
(64-bit) linux than (32-bit) windows xp.

Good luck!

Adam



[R] need automake/autoconf help to build RnetCDF and ncdf packages
Paul Johnson pauljohn32 at gmail.com
 Tue Apr 25 22:46:26 CEST 2006
 I imagine this "where are your header files" problem comes up in other
packages, so I'm asking this as a general R question. How should
configure scripts be re-written so they look in more places?

Briefly, the problem is that Fedora-Extras installs the header files
in a subdirectory /usr/include/netcdf-3 rather than /usr/include:

# rpm -ql netcdf-devel
/usr/include/netcdf-3
/usr/include/netcdf-3/ncvalues.h
/usr/include/netcdf-3/netcdf.h
/usr/lib/netcdf-3/libnetcdf.a
/usr/lib/netcdf-3/libnetcdf_c++.a
/usr/lib/netcdf-3/libnetcdf_g77.a

Last week I posted in this list that I re-built the Fedora-Extras
netcdf rpm so that it would have more standard installation, and then
I was able to make RNetCDF work.

In the meanwhile, I posted in bugzilla.redhat.com asking if they
might use the standard packaging, but their response is an adamant
refusal:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=189734

When netcdf updates are issued in the Fedora-Extras network, the
special hacks I put in to un-do their special hacks are lost, and
netcdf programs don't work anymore.

The attempt to build "ncdf" fails inside R or on the command line, but
it gives a GOOD HINT about a command line work around:

# R CMD INSTALL ncdf_1.5.tar.gz
[...]

checking /sw/include/netcdf.h presence... no
checking for /sw/include/netcdf.h... no

Fatal error: I cannot find the directory that holds the netcdf include
file netcdf.h!
You can specify it as follows:
 ./configure --with-netcdf_incdir=directory_with_file_netcdf.h

 *** Special note for R CMD INSTALL users: *********************************
 The syntax for specifying multiple --configure-args does not seem to be
 well documented in R. If you have installed the netcdf include and library
 directories in some non-standard location, you can specify BOTH these
 during the R CMD INSTALL process using the following syntax:

 R CMD INSTALL
--configure-args="-with-netcdf_incdir=/path/to/netcdf/incdir
-with-netcdf_libdir=/path/to/netcdf/libdir" ncdf_1.1.tar.gz

 where you should, of course, specify your own netcdf include and library
 directories, and the actual package name.
 ***************************************************************************


I found that the following did work!

# R CMD INSTALL
--configure-args="-with-netcdf_incdir=/usr/include/netcdf-3
-with-netcdf_libdir=/usr/lib/netcdf-3" ncdf_1.5.tar.gz

It is not the best solution, because special administrative effort is
required. And the "install.packages" approach inside R won't work.

However, with RNetCDF, the problem is slightly worse, and no such
helpful message appears:

# R CMD INSTALL RNetCDF_1.1-3.tar.gz
* Installing *source* package 'RNetCDF' ...
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for executable suffix...
checking for object suffix... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for main in -lnetcdf... no
configure: error: netcdf library not found
ERROR: configuration failed for package 'RNetCDF'
** Removing '/usr/lib/R/library/RNetCDF'


I have no reason to doubt that the Fedora-Extras authors are right,
and that some changes in the configure scripts for these packages are
required.

In RnetCDF's configure.ac file, I see the place where it specifies the
NETCDF_INCDIR

if test -z "${NETCDF_PATH}"; then
 AC_CHECK_FILE(/usr/local/include/netcdf.h,
 [USR_LOCAL_NETCDF_H=TRUE], [USR_LOCAL_NETCDF_H=FALSE])
 if test "${USR_LOCAL_NETCDF_H}" = TRUE; then
 NETCDF_INCDIR="/usr/local/include"
 NETCDF_LIBDIR="/usr/local/lib"
 NETCDF_LIBNAME="netcdf"
 HAVE_NETCDF_H=TRUE
 elif test "${HAVE_NETCDF_H}" = FALSE; then
 AC_CHECK_FILE(/usr/include/netcdf.h,
 [USR_NETCDF_H=TRUE], [USR_NETCDF_H=FALSE])
 if test "${USR_NETCDF_H}" = TRUE; then
 NETCDF_INCDIR="/usr/include"
 NETCDF_LIBDIR="/usr/lib"
 NETCDF_LIBNAME="netcdf"
 HAVE_NETCDF_H=TRUE
 fi
 fi
else
 NETCDF_INCDIR="${NETCDF_PATH}/include"
 NETCDF_LIBDIR="${NETCDF_PATH}/lib"
 NETCDF_LIBNAME="netcdf"
 AC_CHECK_FILE(${NETCDF_INCDIR}/netcdf.h,
 [INCDIR_NETCDF_H=TRUE], [INCDIR_NETCDF_H=FALSE])
 if test "${INCDIR_NETCDF_H}" = TRUE; then
 HAVE_NETCDF_H=TRUE
 fi

fi

I've tried fiddling around in this, and then typing

#autoconf configure.ac > newconfigure

sh ./newconfigure

But it always ends the same:

checking for main in -lnetcdf... no
: error: netcdf library not found

So, is there somebody here who know how configure scripts ought to be
written to accomodate this?



--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas





-- 
Adam Wilson
http://hydrodictyon.eeb.uconn.edu/people/wilson/
Department of Ecology and Evolutionary Biology
BioPharm 223
University of Connecticut
Tel: 860.486.4157
Adam.Wilson at UConn.edu



More information about the R-help mailing list