[R] R crash with dyn.load

Thibault Helleputte thibault.helleputte at uclouvain.be
Thu Dec 18 17:18:10 CET 2008


I try to incorporate C code in R.

suppose I have the following C code:

#include <R.h>
#include <stdio.h>

int main(int *n)
    int i;
    for(i=0; i < *n; i++) {
        printf("Hello, world!\n");

in a file named "hello.c". First I make:

g++ -c hello.c -o hello.o -I
g++ -dynamic hello.o -o hello.so

I work on mac, and that's why I have to set the -dynamic option. First
of all, I don't understand why I have to specify the path to R.h, but if
I don't, R.h isn't found.

My problem is the following: once the .so is generated, without any
warning or error, I open my R envirronment and type

> dyn.load("/path/to/my/hello.so")

then push on enter, and then R runs  hours, without giving me the
command invite again. What am I doing wrong?

Thank you.

More information about the R-help mailing list