Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29251 Discussions

IVF 9. call Fortran Dll from Borland Delphi

normcler
Beginner
832 Views
Dear IVF comrades,

I'm trying to call a Fortran Dll built with IVF 9.- from Borland Delphi. I've done this with the Lahey/Fujitsu compiler and with CVF, but I'm having some problems. I launch my Delphi app and nothing happens.

Here's the dumpbin /exports design.dll:
dumpbin /exports design.dll
Microsoft COFF/PE Dumper Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file design.dll

File Type: DLL

Section contains the following exports for Design.dll

00000000 characteristics
4341704B time date stamp Mon Oct 03 13:54:19 2005
0.00 version
1 ordinal base
2 number of functions
2 number of names

ordinal hint RVA name

1 0 00001000 design
2 1 00004474 retrieveprimitive

Summary

10ED000 .data
13000 .data1
2D000 .rdata
27000 .reloc
2B8000 .text

Here's the interface to the fortran function design in Delphi:

function DESIGN(var IntParm: IntArray; var RealParm: RealArray;
var RequestParm: RequestArray; var CharacterParm: CharacterArray;
var AuxParm1: CharacterArray; var AuxParm2: CharacterArray;
var AuxParm3: CharacterArray; var AuxParm4: CharacterArray;
var AuxParm5: CharacterArray; var AuxParm6: CharacterArray;
var AuxParm7: CharacterArray; var AuxParm8: CharacterArray;
var AuxParm9: CharacterArray): Longint; stdcall; external 'design.dll';

Here's the interface in Fortran:

function DESIGN (IntArgs, RealArgs, requestBfr, chrctrBfr, AuxBuffer1, AuxBuffer2, AuxBuffer3, Aux
Buffer4, AuxBuffer5,&
& AuxBuffer6, AuxBuffer7, AuxBuffer8, AuxBuffer9) result (DesignReturn)
integer (DefaultInteger), dimension(NO_OF_INT_ARGS) :: IntArgs
real, dimension(NO_OF_REAL_ARGS) :: RealArgs
integer(TinyInteger), dimension(REQUESTLEN) :: RequestBfr
integer(TinyInteger), dimension(BFRLEN), intent(inout) :: ChrctrBfr
integer(TinyInteger), dimension(BFRLEN), intent(in) :: AuxBuffer1, AuxBuffer2, AuxBuffer3, AuxB
uffer4, AuxBuffer5,&
& AuxBuffer6, AuxBuffer7, AuxBuffer8, AuxBuffer9
integer (DefaultInteger) :: DesignReturn

and my DLLEXPORT statement for design:
!DEC$ ATTRIBUTES DLLEXPORT,STDCALL,ALIAS:'design' :: DESIGN

The dll is in a file called design.dll and it's located in the same directory as the Borland executable.

I've tried several different combinations of ATTRIBUTES but they're not working.

Any suggestions?

Norm
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
832 Views
Is it ever called?

If not, does the Delphi caller complain about missing export from the dll?

In particular, I'm suspicious about:
!DEC$ ATTRIBUTES DLLEXPORT,STDCALL,ALIAS:'design' :: DESIGN
...
function DESIGN(...); stdcall; external 'design.dll';
You're exporting symbol "design" but I think Delphi expects "_DESIGN@52". IIRC case matters in Delphi in this case. If I'm right, you can do one of:

- add DECORATE attribute on Fortran side, and lowercase the declaration in Delphi, or
- add name clause in Delphi, i.e. external 'design.dll' name 'design'

Jugoslav
0 Kudos
normcler
Beginner
832 Views
Dear Jugoslav,

I can always count on you to help me with my Fortran-Delphi communication. I decorated my Fortran functions as you suggested, and everything worked fine.

Thank you.

Norm
0 Kudos
Reply