使用 Visual Studio 运行 Fortran DLL [英] Run Fortran DLL with Visual Studio

查看:36
本文介绍了使用 Visual Studio 运行 Fortran DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Visual Studio 2010 开发了一个网站.我想运行 Fortran DLL.我使用 Intel 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 输出作为现有项目添加到项目中, 带有 Add as Link 选项.然后我将它设置为在项目树中较新时复制.

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/Debugbin/Release 文件夹时,它会跟随二进制文件.

In the end it follows the binary when you compile it into the bin/Debug or bin/Release folders.

使用 C# 然后你可以像这样使用 [DllImport()] 属性:

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.

这篇关于使用 Visual Studio 运行 Fortran DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆