使用Visual Studio运行Fortran DLL
我使用Visual Studio 2010开发了一个网站。我想运行一个Fortran DLL。我使用英特尔Visual Fortran创建一个.dll并测试如何使用它。我的代码是:
I develop a website with Visual Studio 2010. I want to run a Fortran DLL. I used Intel Visual Fortran to create a .dll and to test how to use it. My code is:
SUBROUTINE SIMPSON (N,H,I)
!DEC$ ATTRIBUTES DLLEXPORT, DECORATE, ALIAS : "SIMPSON" :: SIMPSON
!DEC$ ATTRIBUTES REFERENCE::N
!DEC$ ATTRIBUTES REFERENCE::H
!DEC$ ATTRIBUTES REFERENCE::I
INTEGER N,H,I
I=N+H
RETURN
END
其实际上需要两个整数,添加它们并返回结果。现在我有.dll我不知道如何使用Visual Studio运行它。任何知道的人都可以告诉我要遵循的步骤吗?
which practically takes two integers, adds them and return the result. Now I have the .dll I don't know how to run it with Visual Studio. Can anyone who knows please give me steps to follow?
我一直都这样做。我在做什么,在调用项目( C#
, VB.NET
)我添加 .dll
作为现有项目输出到项目,其中添加为链接
选项。然后我将其设置为复制,如果在项目树中是较新的。
I do this all the time. What I do, is in the calling project (C#
, VB.NET
) I add the .dll
output to the project as an existing item, with Add as Link
option. Then I set it to copy if newer in the project tree.
最后,当您将其编译到 bin / Debug
或 bin / Release
文件夹。
In the end it follows the binary when you compile it into the bin/Debug
or bin/Release
folders.
使用 C#
然后使用 [DllImport )]
attrbiute这样:
With C#
you then use the [DllImport()]
attrbiute like this:
[DllImport("trex_pc.dll")]
static extern Simpson(ref int N, ref int H, ref int I);
有关详细信息,请参阅这个我的回答。
For more details look at this answer from me.