[R] Calling R from c in Windows XP
Martin Morgan
mtmorgan at fhcrc.org
Sat Mar 27 20:05:47 CET 2010
On 03/27/2010 07:53 AM, dkStevens wrote:
>
> I'm searching for answers to four questions (I've been searching the net for
> hours...)
>
> In Windows XP, is it possible to call R functions from a c program? (I've
> found examples for Linux/Unix but not Windows)
>
> If so, is there a simple example to get started using gcc with R-2.10.0?
Up to this point, the answer is in Writing R Extensions, sections 8.1
and 8.2 (which has a kind of implicit dependency on 8.1). A minimal file
might be
embed_win.c:
#include <Rembedded.h>
int main(int argc, char *argv[])
{
Rf_initEmbeddedR(argc, argv);
run_Rmainloop();
Rf_endEmbeddedR(0);
return 0;
}
and after discovering appropriate compiler args with
R CMD config --cppflags
R CMD config --ldflags
one might (modulo line wrapping in email clients :()
Z:\Home\tmp>gcc -IC:/PROGRA~1/R/R-211~1.0DE/include
-LC:/PROGRA~1/R/R-211~1.0DE/bin -lR embed_win.c
and then
Z:\Home\tmp>a --vanilla
> x = 1:10
> q()
There are more examples in
https://svn.r-project.org/R/trunk/tests/Embedding
Martin
>
> If so, is it possible to write a simple interface using a c dll to call R
> functions from a Visual Basic.net program?
>
> If so, is there a simple example?
>
> Thanks to all
--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
More information about the R-help
mailing list