[R] how to statically load a lib *.a

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon Jan 10 18:11:43 CET 2000

On Mon, 10 Jan 2000, Tony Q. Zhang wrote:

> Hi, 
>    I built a PORT library (libport.a) from NetLib, which contains lots of
> Fortran subroutins. How can I statically load it into R? Or should I
> recompile R with this library?

You just need to dyn.load the code, which means you need to build a shared
library (libport.so).  You could add it by re-compiling, but this should
not be necessary, and you would need to declare the entry points
in src/appl/ROUTINES.

> btw, all I'm trying to do is to port _constrained_ optimization routine
> 'nlregb' into R. It is based on the public routines from netlib. I don't
> know exactly how difficult (or easy) it is. 

It's not at all easy, as you need to pass around and evaluate R expressions
in (in your case) Fortran code and that will require C glue layers.  There
is a function optim() in the development version of R (the basis for the
next release) which has a box-constrained optimizer like nlminb: that might
do what you want.  Alternatively, read the nlm interface code and see if
you really want to do this!

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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list