[R] simple example of C interface to R

jbdunsmo@utmb.edu jbdunsmo at utmb.edu
Tue Feb 8 23:02:34 CET 2005


thanks for all the help.  i've tried everyone's suggestions, to no
avail...

On Tue, Feb 08, 2005 at 04:19:10PM -0500, Huntsinger, Reid wrote:
> Rtest.o is just an object file, and the second call to gcc is really a call
> to ld and creates Rtest.so, a shared library. Neither is executable.
> Probably you want to compile Rtest.c into an executable; it does have the
> "main" function after all. Perhaps 
> 
> gcc -L/usr/local/lib -o Rtest Rtest.o   -L/usr/lib/R/bin -lR
> 
> would work. 

that didn't work:

    $ gcc -L/usr/local/lib -o Rtest Rtest.o   -L/usr/lib/R/bin -lR
    Rtest.o(.text+0x2f): In function `main':
    : undefined reference to `eval_R_command'
    collect2: ld returned 1 exit status
    

On Tue, Feb 08, 2005 at 11:40:08AM -0800, Duncan Temple Lang wrote:
>
> The .o file is object code that is then used when creating an
> executable.   You cannot run it directly.
> You can use the Makefile in that tests/Embedding/ directory
> to build the Rtest application for you. 

    $ cd R-1.9.0/tests/Embedding/
    $ ./configure
    -/bin/bash: ./configure: No such file or directory
    $ make
    make: *** No targets specified and no makefile found.  Stop.
    $ aclocal
    aclocal-1.9: `configure.ac' or `configure.in' is required
    $ automake
    automake-1.9: `configure.ac' or `configure.in' is required
    $ autoconf
    autoconf-2.59: no input file

do i have to write my own configure script?


On Tue, Feb 08, 2005 at 09:42:59PM +0000, Prof Brian Ripley wrote:
> Did none of you notice the Makefile in that directory?
>
> Should be -L`R RHOME`/lib for R>=2.0.0 (and that Makefile needs
> updating). 
> From ONEWS
>
>     o   The dynamic libraries libR and libRlapack are now installed
>     in
>         R_HOME/lib rather than R_HOME/bin.
>
> You may also need to set LD_LIBRARY_PATH: I do to include
> /usr/local/lib.
>

    $ gcc -L`R RHOME`/lib -o Rtest Rtest.o -L/usr/lib/R/bin/ -lR
    Rtest.o(.text+0x2f): In function `main':
    : undefined reference to `eval_R_command'
    collect2: ld returned 1 exit status


it looks like someone's going to have to spell it out for me.




More information about the R-help mailing list