[R] Call R program from C++ code

Vladimir Eremeev wl2776 at gmail.com
Tue Jul 31 07:56:08 CEST 2007


Hi Feng,

You cannot compile R scripts as a shared library.
You can compile the R engine itself (interpreter and some basic functions) as
.dll (or .so), dynamically load it during run time of your application
and call its low level functions.

All details are in the "Writing R extensions" manual, installed with
R (%R_HOME%/doc/R-exts.pdf).

Searching Google with "embedding R" gives the following (outdated) link
http://developer.r-project.org/embedded.html
This says basic things and references the "Writing R Extensions"
manual.

You can see the Rgnome sources for example.

Monday, July 30, 2007, 10:25:16 PM, you wrote:

K> Hi Vladimir:
K> 	Thank you very much! I'm very interested in this sentence: " R can
K> be compiled as a shared library object, that you can dynamically load from
K> your application and use its functions." That's would be great if R programs
K> can be "compiled" as shared library object(.lib? or .dll ? ) Can you please
K> give more details about that? 

K> Best,
K> Feng

K> -----Original Message-----
K> From: r-help-bounces at stat.math.ethz.ch
K> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Vladimir Eremeev
K> Sent: 2007Äê7ÔÂ30ÈÕ 5:16
K> To: r-help at stat.math.ethz.ch
K> Subject: Re: [R] Call R program from C++ code


K> "Writing R Extensions" manual contains chapters dedicated to parsing and
K> evaluating of the R extensions from C.
K> Also, I vaguely remember I've seen something like "Embedding R" somewhere in
K> manuals.
K> R can be compiled as a shared library object, that you can dynamically load
K> from your application and use its functions.
K> R doesn't have a compiler, it's the interpreted language. 
K> However, it can parse a character string representing an expresstion and
K> transform it into the internal form, ready for evaluation.


K> Feng Qiu wrote:
>> 
>> Hi All:
>> 
>>                I'm developing an application program using C++. From my
>> C++
>> code, I would call some R program I have written. I' wondering if R
>> provide
>> some compiler that can compile R program into executable program. I
>> searched
>> R-help, there are a lot of posts talking about writing C++ code in R
>> program, but few about calling R from C++. 
>> 
>>                I might be wrong that R doesn't have complier. What I'm
>> trying to do is to call R program from C++ code. Any help is highly
>> appreciated!
>> 




-- 
Best regards,
 Vladimir                            mailto:wl2776 at gmail.com



More information about the R-help mailing list