[R] Building and loading a DLL on Windows NT

Benjamin.STABLER@odot.state.or.us Benjamin.STABLER at odot.state.or.us
Wed Sep 17 23:14:45 CEST 2003

Thanks.  I didn't try the Borland utility but your response reminded me of a
way to view the DLL info in Windows.  Right click a DLL and then "quick
view" and Windows outputs some file information, including the Export table
which lists the names of the symbols in the DLL.  The name of the add
function is "_Z3addPdS_".  So it works now.  Thanks for your help.

Ben Stabler
Oregon Department of Transportation

>-----Original Message-----
>From: Whit Armstrong [mailto:Whit.Armstrong at tudor.com]
>Sent: Wednesday, September 17, 2003 1:56 PM
>To: STABLER Benjamin
>Subject: RE: [R] Building and loading a DLL on Windows NT
>There's a free utility from borland (I think it's called tdump 
>or dump) that
>will show you all the exports from a dll.  You could run that 
>on the dll you
>made to see what name the function is being exported under 
>(sorry, but I
>don't have the link).  Other than that, it looks like you're doing
>everything right.  I've never built a DLL using SHLIB, so I 
>can't help you
>Good luck,
>-----Original Message-----
>From: Benjamin.STABLER at odot.state.or.us
>[mailto:Benjamin.STABLER at odot.state.or.us] 
>Sent: Wednesday, September 17, 2003 4:52 PM
>To: r-help at stat.math.ethz.ch
>Subject: [R] Building and loading a DLL on Windows NT
>I am trying to build a simple dll with Rcmd SHLIB to link into R.  The
>results of the build are below.  From my limited knowledge of 
>building DLLs,
>it looks like it worked (I didn't get any errors).
>F:\R\dlls> Rcmd SHLIB add.C
>making add.d from add.C
>g++   -IC:/PROGRA~1/R/src/include -Wall -O2   -c add.C -o add.o
>ar cr add.a *.o
>ranlib add.a
>g++  --shared -s  -o add.dll add.def add.a  
>-lg2c -lR
>Then I tried to load the DLL into R with:
>which returned nothing (which I assumes means there were no 
>errors).  But,
>> is.loaded(symbol.C("add"))
>[1] FALSE
>returns false.  add is the name of the function in the source 
>file.  I know
>I can dynamically load other DLLs.  I've read quite a bit of 
>and I am still stumped.  I have all the proper tools for 
>building R under
>Windows and I know they work since I have built Windows 
>package binaries.
>Any ideas on what I am doing wrong would be greatly 
>appreciated.  Thanks.
>Ben Stabler
>R-help at stat.math.ethz.ch mailing list

More information about the R-help mailing list