如何从Fortran调用C DLL?我不在Fortran中编码,但我需要对它进行一些测试。
让我们说在test.dll中有函数:
打开()
Close()方法
如何告诉Fortran使用test.dll?
我的意思是像C#我们可以使用
[DllImport("test.dll")]
static extern uint Open();
我找不到任何可以帮助我的例子。如果你能提供你使用的编译器,我也会更喜欢。
更新
我使用Plato编译器。
我尝试使用此方法加载test.dll。但是,它弹出错误消息,说错误29,调用缺少的例程:_LOADLIBRARY
这是代码。我在网上发现了它。所以不确定我是否正确地做到了。
program test
integer :: p
pointer :: q
p = loadlibrary ("test.dll"C) ! the C at the end says -
! add a null byte as in C
q = getprocaddress (p, "Open"C)
end
修改
对不起。 DLL使用的是C而不是C ++