+ -
当前位置:首页 → 问答吧 → 求救:delphi 调用fortran 编的DLL文件 说无效接口

求救:delphi 调用fortran 编的DLL文件 说无效接口

时间:2011-10-29

来源:互联网

我用fortran编了一个dll文件在delphi上调用,可是每次它都说 无法定位程序输入点Circle_Area于动态链接库forlib.dll上 这是什么问题呢?求救啊。。。。。
下面是dll代码 
real function circle_area(radius)
!DEC$ ATTRIBUTES DLLEXPORT :: CIRCLE_AREA
!DEC$ ATTRIBUTES ALIAS : "Circle_Area" :: CIRCLR_AREA
  implicit none 
  real radius
  real,parameter :: pi=3.14159
  circle_area=radius*radius*pi
  return
end function

integer function sum(a)
!DEC$ ATTRIBUTES DLLEXPORT :: SUM
  implicit none 
  integer :: a(10)
  integer i
  sum=0
  do i=1,10
  sum=sum+a(i)
  end do 

  return
end function 

subroutine makelower(string)
!DEC$ ATTRIBUTES DLLEXPORT :: MAKELOWER
  implicit none 
  character(len=*):: string
  integer:: len,i,code
  len=len_trim(string)
  do i=1,len
  code=ichar(string(i:i))
if (code>=ichar('a').and.code<=ichar('z'))then 
string(i:i)=char(code-32)
end if 
  end do
  return 
end subroutine 

下面是delphi 代码
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
  label1: TLabel;
  edit1: TEdit;
  label2: TLabel;
  label3: TLabel;
  button1: TButton;
  edit2: TEdit;
  button2: TButton;
  label4: TLabel;
  button3: TButton;
  procedure button1Click(Sender: TObject);
  procedure button2Click(Sender: TObject);
  procedure button3Click(Sender: TObject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;

var
  Form1: TForm1;

implementation

function Circle_Area(r:PSingle):Single;stdcall;external'forlib.dll';
function SUM(r:array of LongInt):LongInt;stdcall;external'forlib.dll';
function MAKELOWER(r:string;i:LongInt):string;stdcall;external'forlib.dll';

{$R *.dfm}

procedure TForm1.button1Click(Sender: TObject);
var s,a:Single;
begin
  s:=StrToFloat(edit1.Text);
  a:=Circle_Area(Addr(s));
  label3.Caption:=FloatToStr(a);

end;

procedure TForm1.button2Click(Sender: TObject);
var s:string;
begin
  s:=edit2.Text;
  MAKELOWER(s,Length(s));
  edit2.Text:=s;
end;

procedure TForm1.button3Click(Sender: TObject);
var s:array [1..10] of LongInt;
var i,total:LongInt;
begin
 for i:=1 to 10 do
 begin
  s[i]:=Random(9)+1;
 end;
 label4.Caption:=IntToStr(s[1]);
 for i:=2 to 10 do
 begin
  label4.Caption:=label4.Caption+'+'+inttostr(s[i]);
 end;
 total:=SUM(s);
 label4.Caption:=label4.Caption+'='+inttostr(total);
end;

end.



哪位高人指点一下吧,我是初学者,实在不会。。。。在这先谢过了。。。。

作者: Katie0305   发布时间: 2011-10-29

fortran,牛人,帮你顶

作者: learning8899   发布时间: 2011-10-31