[R] Calling C routine in anther package in C code (R_RegisterCCallable)

From: Alex Chen <ychen_at_insightful.com>
Date: Fri, 01 Jun 2007 12:18:26 -0700


I want to make use of some C routines from other packages to write extensions in C.  

In "Writing R Extensions", it says there is an experimental interface to support this in (or from ?) R 2.4.0.  

I had a dummy library containing src/dummy.cpp and R/zzz.R:  

#include <R.h>

#include <Rinternals.h>

#include <R_ext/Rdynload.h>

extern "C"


  void dummy(int *a, int *b)





void R_init_dummy(DllInfo *dll)


  R_RegisterCCallable("dummy", "dummy", (DL_FUNC)dummy);


.First.lib <- function(lib, pkg) {

  library.dynam("dummy", pkg, lib)



I can compile this using R 2.5.0 under Linux.  

But I got the following error when I tried to load the library  


Error in dyn.load(x, as.logical(local), as.logical(now)) :

        unable to load shared library

  /homes/ychen/Rlibs/dummy/libs/dummy.so: undefined symbol: _Z19R_RegisterCCallablePcS_PFPvvE

Error in library(dummy) : .First.lib failed for 'dummy'  

Can anyone help me out?  



        [[alternative HTML version deleted]]

R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 01 Jun 2007 - 19:25:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Jun 2007 - 20:33:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.