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

From: Adam Wilson <>
Date: Thu, 13 Mar 2008 11:09:38 -0400

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:


If this does not work, check RnetCDF's 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!


[R] need automake/autoconf help to build RnetCDF and ncdf packages Paul Johnson pauljohn32 at
 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

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 asking if they might use the standard packaging, but their response is an adamant refusal:

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

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

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


 elif test "${HAVE_NETCDF_H}" = FALSE; then  AC_CHECK_FILE(/usr/include/netcdf.h,




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

#autoconf > 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
Department of Ecology and Evolutionary Biology
BioPharm 223
University of Connecticut
Tel: 860.486.4157

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 13 Mar 2008 - 15:18:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Mar 2008 - 15:30:22 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive