[R] dyn.load problem
O. Neto
otnetobr at yahoo.com.br
Fri Nov 12 13:31:05 CET 2004
Hi R-Users
I wrote 1 week ago asking about a message that appears when I try run
dyn.load.
I'm trying to do an example in C code from "Writing R Extension" to
learn how to do it.
I have R 2.0.0, Rtools, Perl and MinGW as describe in
http://www.murdoch-sutherland.com/Rtools/ with path sets.
When I use C:\R\rw2000\bin>RCMD SHLIB -o C:/dev-cpp/teste.dll
C:/dev-cpp/conv.c
a teste.dll is created without error and located in that directory, but when
I use it in RGui with "Change dir" set to C:/dev-cpp :
>dyn.load("teste.dll") results:
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library "C:/Dev-Cpp/teste":
LoadLibrary failure: Parâmetro incorreto. (Incorrect Parameter)
My C code is (extracted form Writing R Extension):
#include <R.h>
#include <Rinternals.h>
SEXP convolve2(SEXP a, SEXP b)
{
R_len_t i, j, na, nb, nab;
double *xa, *xb, *xab;
SEXP ab;
PROTECT(a = coerceVector(a, REALSXP));
PROTECT(b = coerceVector(b, REALSXP));
na = length(a); nb = length(b); nab = na + nb - 1;
PROTECT(ab = allocVector(REALSXP, nab));
xa = REAL(a); xb = REAL(b);
xab = REAL(ab);
for(i = 0; i < nab; i++) xab[i] = 0.0;
for(i = 0; i < na; i++)
for(j = 0; j < nb; j++) xab[i + j] += xa[i] * xb[j];
UNPROTECT(3);
return(ab);
}
I´m using RCMD under Windows ME.
How can I fix this? Someone can help me ? Prof. Ripley told me to catch
more information debbuging this DLL. Is it hard to do this one under
Windows? It´s necessary modify files SHLIB or MkDLL?
Thanks
O. Neto
More information about the R-help
mailing list