Skip to content

dyn.load problem

4 messages · O. Neto, Uwe Ligges

#
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 :
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
1 day later
#
O. Neto wrote:

            
Really, *really* sure you have followed all of readme.packages?
Works for me.
What is the output?
>
Not that easy as under Linux, at least.


Uwe Ligges
#
Hi, Uwe.

    Thank you for help.

    Yesterday another R-user Mr. Ramasamy told me to do a simple program
such as (changing too the directories, now C:/minhadll/):

/*file conv.c*/

#include <R.h>
void printhello (){
  Rprintf("%s", "hello world\n");
}

    When I use C:\R\rw2000\bin>RCMD SHLIB -o c:/minhadll/meuteste.dll
c:/minhadll/conv.c
 to compile this one. Below is the output.

C:\R\rw2000\bin> RCMD SHLIB -o c:/minhadll/meuteste.dll c:/minhadll/conv.c
making c:/minhadll/conv.d from c:/minhadll/conv.c
gcc   -IC:/R/RW2000/include -Wall -O2   -c c:/minhadll/conv.c -o
c:/minhadll/conv.o
ar cr c:/minhadll/meuteste.a c:/minhadll/conv.o
ranlib c:/minhadll/meuteste.a
gcc  --shared -s  -o c:/minhadll/meuteste.dll c:/minhadll/meuteste.def
c:/minhadll/meuteste.a  -LC:/R/RW2000/src/gnuwin32  -lg2c -lR

    The result is " meuteste.dll"  located in C:/minhadll/meuteste.dll. Now,
talking about paths:
    I believe that I have make a correct way... but I'll list here to you:

SET PATH=C:\Rtools\;C:\Perl\bin\;C:\MinGW\bin;C:\R\rw2000\include\
        Is it correct?
Thank you again for help me. I'm trying to do a dll for 3 weeks or more,
without a good result.

PS: The same error dyn.load appears


O. Neto
#
O. Neto wrote:

            
I'd rather vote for
set PATH=.;C:\Rtools;C:\Perl\bin;C:\MinGW\bin;%PATH%

Anyway, this doesn't seem to be the culprit.
Do you have the recommended tools in their most recent versions?

The last point might be your OS. I think nobody of the developers is 
working on non-NT based Windows versions (such as 95, 98, ME) these days.


Uwe Ligges