[R] Linking a library with init(argc,argv) function
Maxime Debon
maxime.debon at etudiant.univ-rennes1.fr
Wed Dec 10 21:12:12 CET 2008
Hi,
I would like to embed the LibMesh library in R. I have already linked
C++ code and build libraries as it is explained in the R-extension
manual with trivial examples :
dyn.load(paste("/home/default/LibFooR",.Platform$dynlib.ext,sep=""))
I am facing a difficulty with loading a library depending on a library
(libMesh) which needs an initialization function (libMesh::init(argc,
argv);).
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);
};
}
___________________________________
This way, it doesn't seem possible to put arguments argc and argv. To
go further and link LibMesh, an "int main( int argc, char** argv )"
might have to be specified during the launching of R. May be the
".First.lib" and the "library.dynam" load functions are necessary.
But, even that way I am not able to perform the link. At the moment,
segmentation fault is still the result with fake argc and argv.
If anyone has elements to proceed and implement "init(argc, argv)", it
would be great,
Thanks,
Maxime
More information about the R-help
mailing list