[R] Strange problems with compiling dll
Romain Francois
romain at r-enthusiasts.com
Fri Dec 3 08:07:15 CET 2010
Hello,
Your question is more appropriate on the R-devel mailing list.
Le 03/12/10 00:41, Oleksandr Dyklevych a écrit :
>
>
> 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
What does that mean ? What did you try ?
R CMD SHLIB mycomin.c
definitely works for me. What part of "Writing R Extensions" was not clear ?
Romain
> 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
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/hovakS : RcppGSL initial release
|- http://bit.ly/iaxTdO : parser 0.0-12
`- http://bit.ly/gnCl01 : Rcpp 0.8.9
More information about the R-help
mailing list