Making and using a DLL consists of three major steps
Let us consider a simple Fortran 77 program
vecsum.f
which sums up a vector:
C2345.7890123456789012345678901234567890123456789012345678901234567890 C C function sum(x, nn, s) double precision nn,s double precision x(nn) integer i,n,sum n=int(nn) s=0.0 do 10 i=0, n s=s+x(i) 10 continue sum=0 return end
As a first step we create a project called vecsum.gui
to generate a Windows DLL:
vecsum.f
to C:\vecsum
Compiler Interface
Name
the project name vecsum
and under Location
the directory C:\vecsum
OK
Target Type
the radio button Dynamic-Link Library
DLL
the box Export All Routines and Data
OK
Add/Remove file(s)
vecsum.f
Add
and then Close
The second step consists of compiling the code:
Build
to compile the DLL
To use the DLL in XploRe requires the following simple steps.
x
and initialize the result s
x=1:10 s=0
h=
dlopen
("vecsum.dll")
Note that XploRe needs to be able to find this library. From
XploRe you can set the path for DLLs by
setenv
("xpl4dll","/your_absolute_path_to_the_dll")
Alternatively you can give the absolute path within the
dlopen
command.
sum
from the DLL for x
dlcall
("_sum",x, rows(x),s)
As a result you should find s
having the value 55 which
is the sum for the numbers 1 to 10.