Run Fortran DLL with Visual Studio

蓝咒 提交于 2019-11-28 11:49:32
ja72

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.

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

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.

You could simply create a Console project in IVF and link in your DLL. That may require producing a .lib file containing references to your DLL. I'm not 100% sure how to do that, although perhaps it was automatically created for you.

After the library is linked in, you can simply call simpson and it should work.

GerritV2

You can use the Post-Build Event in the dll Property Pages:

  • Click right on DLL-project in Solution Explorer
  • goto Build Events - post-Build Events
  • Command Line copy/y "$(OutDir)\$(ProjectName).dll" "$(SolutionDir)\bin\debug\" The DLL will be copied each time you build the DLL or Solution. The target location might be different.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!