On 3 December 2010 at 08:46, Oleksandr Dyklevych wrote:
| I'm trying to speed up my R code by writing quite simple dll's in C.
But I
Yes, that can be a very appropriate approach and many tools help. Make sure
you read the 'Writing R Extensions' manual though.
| 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 ===|
The error messages make me suspect that you are using an unsupported
toolchain. That is your right, but you are unlikely to find help. All
documentation suggests to use the gcc/g++ combinations (with minor exceptions
such as the native Solaris compiler etc pp).
| 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
That is very clearly unsupported. Re-visit 'Writing R Extensions', in
particular the Appendix on the Windows toolchain, and try again.
| 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?
No. That approach is clearly documented as being unsupported -- so you cannot
expect answers on the principal development list for R.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com