Re: [R] A question regarding package development

From: Prof Brian Ripley <>
Date: Fri, 01 Jun 2007 06:40:30 +0100 (BST)

On Thu, 31 May 2007, Saptarshi Guha wrote:

> Hi,
> I am writing a package which requires the ANN(Approx N.Neighbors)
> library (found here
> My package directory looks something like this
> atry/
> atry/src/ann/ <--ann source is here
> atry/src/ann/include
> atry/src/ann/lib <--ann lib file is here
> atry/src/disp.cpp < my file which requires the ann lib
> The last file disp.cpp has the include line
> include "ann/ann.h"
> How do i modify the R CMD INSTALL process so that i can
> 1) build the ann library

You would need to add a src/Makefile. There are several examples in CRAN packages. Matrix is one, but a complex one. Runuran is a simple one, unfortunately specific to GNU make.

> 2) provides include paths and lib paths to the R CMD INSTALL process
> so that atry/src/disp.cpp (my program) can locate the libs and
> header files and succesfully compile.
> I tried using Makevars (in the src folder) and adding a INCPATH and
> LIBS= however that didn't work - the compilation didn't take into
> account the modified INCPATH.

`Writing R Extensions' tells you about PKG_CPPFLAGS and PKG_LIBS, in the section on 'Makevars', so I don't understand why you used different names. There are lots of examples in CRAN packages.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 01 Jun 2007 - 06:08:54 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 Fri 01 Jun 2007 - 07:31:41 GMT.

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