c++调用fortran的dll问题
调用fortran编的dll出现以下错误:
hehe.exe 中的 0x00000000 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突
这个怎么解决呀!
下面是fortran的源码:(就是简单的显示a的值)
subroutine sub(a)
! Expose subroutine sub to users of this DLL
!
!MS$ ATTRIBUTES DLLEXPORT::sub
! Variables
implicit none
integer::a
write(*,*) a
return
! Body of sub
end subroutine sub
下面是我用vs2008调用:
#include "stdafx.h"
#include
#include
void main()
{
int a =10;
HINSTANCE myInstance;
myInstance =LoadLibrary(_T("sub.dll"));
if (myInstance ==NULL)
{
return;
}
typedef void(_stdcall*sub)(int *a);
sub myfft;
myfft =(sub)GetProcAddress(myInstance,"myfft");
myfft(&a);
FreeLibrary(myInstance);
}
编译可以通过,但在运行中就会出现上述问题(0x00000000 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突)
请大家帮帮忙啊
hehe.exe 中的 0x00000000 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突
这个怎么解决呀!
下面是fortran的源码:(就是简单的显示a的值)
subroutine sub(a)
! Expose subroutine sub to users of this DLL
!
!MS$ ATTRIBUTES DLLEXPORT::sub
! Variables
implicit none
integer::a
write(*,*) a
return
! Body of sub
end subroutine sub
下面是我用vs2008调用:
#include "stdafx.h"
#include
#include
void main()
{
int a =10;
HINSTANCE myInstance;
myInstance =LoadLibrary(_T("sub.dll"));
if (myInstance ==NULL)
{
return;
}
typedef void(_stdcall*sub)(int *a);
sub myfft;
myfft =(sub)GetProcAddress(myInstance,"myfft");
myfft(&a);
FreeLibrary(myInstance);
}
编译可以通过,但在运行中就会出现上述问题(0x00000000 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突)
请大家帮帮忙啊