[19006] in s-news-athena

home help back first fref pref prev next nref lref last post

Re: [S] dll.load() with mingw32/gcc-g77

daemon@ATHENA.MIT.EDU (Prof Brian D Ripley)
Mon Aug 23 03:02:57 1999

Date: Mon, 23 Aug 1999 07:55:52 +0100 (BST)
From: Prof Brian D Ripley <ripley@stats.ox.ac.uk>
To: Ignatius Reilly <ar_menio@yahoo.com>
Cc: s-news@wubios.wustl.edu
In-Reply-To: <19990822234300.16169.rocketmail@web123.yahoomail.com>
Message-Id: <Pine.GSO.4.05.9908230739320.1563-100000@auk.stats>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


Fortunately, I tested this all out last week for writing up.

On Sun, 22 Aug 1999, Ignatius Reilly wrote:

> I'm trying to load some f77 code by building a DLL and then using
> dll.load() on S+2000 under Win98 (as some tech-support people suggested
> earlier on this list).

I think it was me replying to Andrew Bruce , and we are _not_ `tech support
people' who in any case are full members of the human race, have names and
deserve credit and thanks.

> I've downloaded the last version of mingw32/gcc (2.95) and everything
> seems to work fine. 

Yes, does for me. You might want to try the msvcrt-runtime version.
And by defining _MSC_VER the S-PLUS header files can be used with C files
(under 2000 and perhaps 4.5).

> In order to build the .dll file I follow some instructions in the
> "ftp://.../gnu-win32/mingw32/misc/README.dllhelpers" file.
> 
> Specifically on the MS-DOS prompt I type:
> 
> g77 -c -g -o mys.o mystuff.f
> dlltool --export-all --output-def mys.def mys.o
> dlltool --dllname mys.dll --def mys.def --output-lib mys.a
> dllwrap --driver-name g77 --def mys.def -o mys.dll mys.o mys.a

Just 

g77 -c -o mys.o mystuff.f
dllwrap --export-all-symbols -o mys.dll mys.o

I think your solutions export no symbols, unless --export-all-symbols
can be abbreviated. You don't need an export lib for your own .o.

> then, on S+2000/Win98 I type
> 
> > dll.load("[path]/mys.dll")

That loads no symbols at all. Try

dll.load("[path]/mys.dll", call="cdecl", symbols="mystuff_")

> [1] 1
> > .Fortran('mystuff',...)
> Error in .Fortran("mystuff",: "MYSTUFF" is not a symbol in the load
> tabl

That needs to be

.C("mystuff_", ....)

that is, use .C,  write the symbol in l/case, append `_'.

Try to get hold of pedump (which you can find on the net, if you look
hard enough: it seems less obvious than it used to be) and run

pedump -e mys.dll

This will tell you what you are exporting and how the symbols have been
mangled.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post