[R] Strange problems with compiling dll

Oleksandr Dyklevych diklevich at gmail.com
Fri Dec 3 00:41:32 CET 2010


Dear sir\madam!

I'm trying to speed up my R code by writing quite simple dll's in C. But I  
faced some problems, and I cannot determine their source.

#include <Rinternals.h>

SEXP mycombin(SEXP N, SEXP k){
     int i, *j, *l, c;
     j = INTEGER(k);l = INTEGER(N);
     c = 1;
     if(j[0] > 0 && j[0] < l[0]){
         if(j[0] <= l[0] - j[0]){
             for(i = l[0]; i >= l[0] - j[0] + 1; i--){
                 c = c * i / (l[0] - i + 1);
             }
         }
         else{
             for(i = l[0]; i <= j[0] + 1; i++){
                 c = c * i / (l[0] - i + 1);
             }
         }
     }
     return ScalarInteger(c);
}

But, when I try to compile it I have 5 errors, and all of them come form  
linker and say next (Code::Blocks):

||=== mcb2, Release ===|
obj\Release\conv.o:conv.c|| undefined reference to `INTEGER'|
obj\Release\conv.o:conv.c|| undefined reference to `INTEGER'|
obj\Release\conv.o:conv.c|| undefined reference to `Rf_ScalarInteger'|
obj\Release\conv.o:conv.c|| undefined reference to `Rf_ScalarInteger'|
obj\Release\conv.o:conv.c|| undefined reference to `Rf_ScalarInteger'|
||=== Build finished: 5 errors, 0 warnings ===|


I found out that I need to link Rdll.lib, but to make it I should use  
these instructions

make R.exp
lib /def:R.exp /out:Rdll.lib

but i cannot figure out where I should use them.
I'm trying from here C:\Rtools\src\gnuwin32 but each time i get
make: *** No rule to make target `R.exp'.  Stop.

So where should I state this rule and which rule?...

Will you help me, please, to "connect" my C compiler to R?

Best regards,
Oleksandr



More information about the R-help mailing list