 |
|
List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] external calling fortran on windows
| [MUG] external calling fortran on windows |
|
Author: Theodore Kolokolnikov
Posted: Thu, 16 May 2002 06:09:34 -0700
|
>> From: Theodore Kolokolnikov "tkolokol"
Hello,
I have been trying to call fortran code from maple7 on windows. However no
matter what I try, I keep getting:
> test := define_external('test',LIB="test.dll");
Error, external lookup of test: The specified procedure could not be
found.
The contents of test.f are as simple as you can get, namely:
subroutine TEST
end subroutine TEST
Has anyone successfully done this? I'm using DIGITAL visual fortran from
DEC using developer studio from microsoft (this is standard setup)...
I have looked around the web for documentation; i've also tried to follow
Helmut Kahovec's postings (see
http://lists.adeptscience.co.uk/mug/mug_Jul_2001/shid_585c1802168af8f7f926e3d3767dc62d.html)
however he is using microsoft C which I dont have...
I'm at a loss this far. I wish Maple would have a better documentation
about this (for example step-by-step instructions on how to create dll
with proper options for windows/fortran....)
I don't have Microsoft C/C++ but I do have a free "lcc" compiler which is
able to generate dll. If anybody has been able to use "lcc" for this, I
would be grateful to know how as well. I'd be willing to use C rather than
fortran.
It is a pity that this is such frustrating procedure; I bet many people
have tried and given up on doing this because of lack of proper
documentation.
Theodore.
|
| [MUG] RE: external calling fortran on windows |
|
Author: Alec Mihailovs
Posted: Tue, 21 May 2002 18:10:02 -0400
|
>> From: Alec Mihailovs "amihailo"
Maple couldn't access TEST because it was not exported.
The subroutine test should contain something like this:
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'TEST' :: TEST
or
!DEC$ ATTRIBUTES DLLEXPORT :: TEST
!DEC$ ATTRIBUTES ALIAS:'TEST' :: TEST
Also, the procedure define_external might need including FORTRAN:
test := define_external('test','FORTRAN',LIB="test.dll");
The procedure of using lcc for creating dll is described in
http://www.q-software-solutions.com/lccwin32/manual/Advanced.htm
I don't have access to Visual Fortran and lcc at the moment and I
don't want to post detailed instructions without checking them first.
Recently I posted a description of using Visual Studio 6 for
creating dll. I will explain here how to use the best free compiler
available, cygwin gcc, for creating dlls.
First, one should obtain the compiler, downloading the complete
cygwin system from http://cygwin.com .
Second, download the instructions for dll creations,
dllhelpers-0.4.0.tar.bz2 and hello-1.0.tar.gz from
http://www.neuro.gatech.edu/users/cwilson/cygutils/dll-stuff/index.html
Start cygwin clicking on the desktop icon. Type
rxvt -sl 2000 -e bash&
That will start rxvt which looks better that the standard DOS prompt.
We will use it for further typing.
Suppose that you downloaded dllhelpers in your home folder,
C:\cygwin\home\Alec (for me). In that case type
bzip2 -d -c dll* | tar xv
That will decompress the files and extracts them into the
dllhelpers-0.4.0 folder. Then, type
cp -r dll*/c mapledll
That will create a directory mapledll and copy files from the
directory dllhelpers-0.4.0/c into it. Switch to that directory:
cd mapledll
Now we need to edit Makefile. Type
vim Makefile
Type :9 and hit enter. That will move the cursor to line 9,
starting from CFLAGS; then type A. That will move cursor to the
end of the line and switches to the text inserting mode. Type
the following, starting from a space,
-mrtd -mno-cygwin
Then click Esc key at the top left corner of the keyboard,
type :wq and hit enter. That will save your changes.
Don't be discouraged if something goes wrong during the process.
In the worst case just hit escape, type :q! and hit enter. That will
return you to the bash leaving the file unchanged, so you could try again.
Certainly, instead of vi one can use a windows text editor saving UNIX
type line endings. PFE is a good free text editor, for instance.
Without adding those 2 flags, a dll will be created, but will be
unusable from Maple. Now, when you made the necessary changes to
the Makefile, and you returned from vim to a bash prompt, type
make
That will create a dll containing many mathematical functions.
To check if the dll was created correctly, type
./usedll
and look at the results. If everything looks OK, start Maple 7,
and try to access some of the dll functions from Maple. For the
first function it will look as follows:
> int_square := define_external(
> 'dll_int_square',
> 'i'::integer[4],
> 'RETURN'::integer[4],
> LIB="C:/cygwin/home/Alec/mapledll/cygcdll.dll"):
> int_square(5);
25
It is easy to modify it for the other functions in the dll. One
can find their names either in cdll.c, or in usedll.c .
Good luck,
Alec Mihailovs
http://webpages.shepherd.edu/amihailo/
-----Original Message-----
>> From: Theodore Kolokolnikov "tkolokol"
I have been trying to call fortran code from maple7 on windows. However no
matter what I try, I keep getting:
> test := define_external('test',LIB="test.dll");
Error, external lookup of test: The specified procedure could not be
found.
The contents of test.f are as simple as you can get, namely:
subroutine TEST
end subroutine TEST
I don't have Microsoft C/C++ but I do have a free "lcc" compiler which is
able to generate dll. If anybody has been able to use "lcc" for this, I
would be grateful to know how as well. I'd be willing to use C rather than
fortran.
|
Previous by date: [MUG] Legend help in Maple, Christopher
Next by date: [MUG] Re: 3D surface plotting from data points, Maple User Group
Previous thread: [MUG] limit doesn't always work?!? I must be doing smth wrong!, Florin Sabau
Next thread: [MUG] 3D surface plotting from data points.,
|
|
|