[R] Error when calling a dll procedure

Bernd Holleczek bernd.holleczek at gmx.de
Sun Nov 16 20:18:33 CET 2003


Dear experts,

I am a beginner in R and try to build dlls (Win XP, MinGW, R 1.7.1).
So far, I have managed to create and to use some dlls with C code which
worked properly.

Now I am stuck with a dll containing C++ code.

I have included some part of the source code (of an implementation of a
function to find all primes below a given numeric value -> its just an exercises
to get familar with R/C++).

>#include <vector>
>
>using namespace std;
>
>extern "C" {
>#include <R.h>
>#include <Rdefines.h>
>}
>
>SEXP getPrimes(SEXP a)
>{ 
>SEXP c;
>
 
//my implementation

>
>return c;
>}

Here is the output (hopefully without any typos) of the process building the
dll:

>Rcmd SHLIB Primes.cc
>making Primes.d from Primes.c
>g++ -IE:\programs\R\rw1071\src\include -Wall -02 -c Primes.cc  -o Primes.o
>ar cr Primes.a *.o
>ranlib Primes.a
>g++ --shared -s -o Primes.dll Primes.def Primes.a
-LE:\programs\R\rw1071\src\gnuwin32 -lg2c -lR


My PROBLEM is now that I can load the dll (no error message), but not access
the function "getPrimes". Here is some output of the R console:

>> dyn.load("E:\\R_work5\\Primes")
>> .Call("getPrimes", 100)
>Error in .Call("getPrimes", 100) : .Call function name not in load table


Has anybody been confronted with the same kind of difficulties?
I'll appreciate suggestions on how to fix the problem.
Thanks.

Regards,

Bernd Holleczek



-- 
Bernd Holleczek <bernd.holleczek at gmx.de>




More information about the R-help mailing list