Thanks to all the S-users who helped me conquer the folowing problem. I am
particularly indebted to Matt Calder, who even supplied me with a sample
code of using the FORTRAN/C interface.
Using DUMPBIN helped (as I could see that my symbol was not loaded) and
Pierre Duchese's (and Matt) information on setting up the *.def file.
#######
I am trying to load a "dll" in S-Plus 2000. I compiled the my code using
Compaq Visual Fortran 6, and now I am unable to use the code in S.
The name of my SUBROUTINE in Fortran is "bmlogit", and the statement I use
is given below, which the result I get.
dll.load("c:\\data\\fortran\\blogit.dll", symbol ="bmlogit_")
Warning messages:
Warning in dll.load("c:\\data\\fortran\\blogit.dll", symbol = : Unable to
find entry 'bmlogit_' in DLL 'c:\data\fortran\blogit.dll'
[1] 1
Thanks in advance for your help.
Vumani Dlamini
#######
Response from, Matt Calder
Anyway, I can probably help you with your problem. The problem is that
the symbols generated for functions by the compiler are not necessarily the
sameas those you specified in your code. In particular Fortran will often
capitalizethe name (ie. BMLOGIT), and Microsoft compilers will often append
a number that indicates the size in bytes of the arguments (eg. BMLOGIT@16,
if bmlogit takes four arguments (typically Fortran passes by reference and
pointers are 4 bytes on PC's)).
In order to find out what your compiler is calling your function you can use
the File Explorer in Windows (not Internet Explorer). Open the directory
containing your file and right click it, select 'Quick-view' from the menu,
this will list a lot of information including the symbol names defined in
the dll.
(You might be able to find free software on the internet that does this too,
the name pview comes to mind). A common problem people have is that the dll
does not export their symbol at all, if you do not see the bmlogit symbol
referenced at all doing the above, let me know and I'll help you with
exporting.
#######
Response from, "pierre duchesne" <pierre.duchesne@hec.ca>
Exactly what I m using; use something similar to
dll.load("d:\\Programmation\\ANALYS~1\\Spectre.dll", c("XPGRAM",
"LISTWOUT","SPECDAN") )
Also, maybe you have the same problem that me at the very beginning. in your
fortran code, do not forget to do a DLLEXPORT:
# --- Example ---
subroutine myacf(n,serie,acf)
!dec$ attributes dllexport :: myacf
(code)
return
end
# --- end of example ---
#######
Response from, Prof Brian Ripley <ripley@stats.ox.ac.uk>
The problem seems clearly stated to me! Use a utility to find out what(if
any) sysmbols your dll exports. (E.g. pedump or dumpbin.)
Guesses:
1) You forgot to set up any exports via a .def file.
2) you have set flags which mean that the exported symbol is not
what you think it is.
The first is pretty common ....
######
Response from, "Michael Conklin" <mconklin@customresearch.com>
I believe your symbol should be bmlogit=_bmlogit@4*numparams for
example if you pass 8 parameters to bmlogit then the symbol would be
symbols=list(bmlogit=_BMLOGIT@32)
By the way - one thing I really like about the candidate release of version
6 is that all the symbols are loaded automatically. This way if I change my
subroutine (for example to send more parameters to it) I only have to change
my S function that calls the subroutine instead of
having to also change the dll.load function in my .first routine.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
|