[R] A question regarding package development

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 1 07:40:30 CEST 2007


On Thu, 31 May 2007, Saptarshi Guha wrote:

> Hi,
> 	I am writing a package which requires the ANN(Approx N.Neighbors)
> library (found here http://www.cs.umd.edu/~mount/ANN/).
> 	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,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list