Re: [Rd] Qs on calling R from C

2009-06-06 Thread Kynn Jones
On Sat, Jun 6, 2009 at 5:31 PM, Dirk Eddelbuettel wrote: > > Try reading 'R Extensions' section 8.1 entitled 'Embedding R under > Unix-alikes'. That was just what I needed! All it took was adding a single line before the call to mkString (and adding one more header file): #include #include

Re: [Rd] Qs on calling R from C

2009-06-06 Thread Dirk Eddelbuettel
On 6 June 2009 at 17:03, Kynn Jones wrote: | Consider the following simple C program: | | /*** hello_r.c ***/ | #include | | SEXP hello() { | return mkString("Hello, world!\n"); | } | | int main(void) { | SEXP x = hello(); | return x == NULL; /* i.e. 0 on success */ | } | | Thi

[Rd] Qs on calling R from C

2009-06-06 Thread Kynn Jones
Consider the following simple C program: /*** hello_r.c ***/ #include SEXP hello() { return mkString("Hello, world!\n"); } int main(void) { SEXP x = hello(); return x == NULL; /* i.e. 0 on success */ } This program segfaults: % myR/bin/R CMD LINK gcc -I./R-2.9.0/src/include -L.