求救: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.
哪位高人指点一下吧,我是初学者,实在不会。。。。在这先谢过了。。。。
下面是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
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28