[R] Linking a library with init(argc,argv) function

Dirk Eddelbuettel edd at debian.org
Wed Dec 10 21:42:02 CET 2008


On Wed, Dec 10, 2008 at 09:12:12PM +0100, Maxime Debon wrote:
> I am facing a difficulty with loading a library depending on a library  
> (libMesh) which needs an initialization function (libMesh::init(argc,  
> argv);).

Create 'fake' argc/argv as eg in

    char *myargv[] = { "somename",  "--foo", "--bar"};
    int myargc = (sizeof(myargv) - sizeof(myargv) ) / sizeof(myargv[0]);
    init(myargc, myargv);

obviously, --foo and --bar need to be supported by the library in
question.  Else just do

    char *myargv[] = { "somename" };

> Conventionally, the way to make a bridge between R and C is :
> ___________________________________
>
> extern "C" {
>
> void foo_R(double* output, double* S,  double* K){
>
>
>   *output = foo(*S,*K,*r,*sigma,*time);

Black/Scholes, eh? 

Dirk


-- 
Three out of two people have difficulties with fractions.



More information about the R-help mailing list