在excel / fortran dll连接中遇到文件位置问题 [英] Trouble with file location in excel/fortran dll connection

查看:127
本文介绍了在excel / fortran dll连接中遇到文件位置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

平台:WinXP SP2,Intel Fortran 11,Excel 2007

Platform: WinXP SP2, Intel Fortran 11, Excel 2007

我无法连接dll文件与excel。

I'm having trouble connecting a dll file with excel.

dll文件相对简单:

The dll file is relatively simple:

subroutine FortranCall (r1, num)
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS:"FortranCall" :: FortranCall
integer, intent(in) :: r1
character(10), intent(out) :: num
!DEC$ ATTRIBUTES REFERENCE :: num

num = ''
write (num,'(i0)') r1 * 2

return
end subroutine FortranCall

build with: ifort / nologo / dll Fcall.f90 并且之后复制到C盘上的temp目录(在这里如何写反斜杠,反正(除了复制/粘贴)?

build with: ifort /nologo /dll Fcall.f90, and after that copied to "temp" directory on C drive (how does one write a backslash in here, anyway (except copy/pasting) ?)

我有一个Excel文件,在Sheet1中:

and I have an Excel file with, in Sheet1:

Private Sub CommandButton1_Click()
Dim r1 As Long
Dim num As String * 10

     r1 = 123
     Call FortranCall(r1, num)

     TextBox1.Text = "Answer is " & num

End Sub

和Moduel1:

Declare Sub FortranCall Lib "C:\temp\Fcall.dll" (r1 As Long, ByVal num As String)

运行时报告错误:运行时错误53,找不到文件c:\temp\ fcall.dll

When ran it reports an error: runtime error 53, file not found c:\temp\fcall.dll

任何人都有任何线索可能出错? / p>

Anyone has any clue what could be wrong ?

推荐答案

我知道这是一个非常古老的问题,但是有一天我遇到这个问题,以为我会提出一个答案为后代。我的VBA代码调用Fortran DLL在我的电脑上工作正常,但不在我老板或其他人的电脑上。尽管在释放模式下编译而不是调试,但是问题最终是依赖于其他DLL。我使用 Dependency Walker 来检查DLL无法工作的计算机上的依赖关系,发现两个DLL它与需要的intel编译器一起提供,并使用我自己编译的DLL进行分发。

I know this is a very old question, but I came across this issue the other day and thought I'd put an answer up for posterity. My VBA code calling a Fortran DLL worked fine on my computer, but not on my boss's or anyone else's computer. The problem ended up being dependency on other DLLs, despite compiling in "release" mode instead of "debug". I used Dependency Walker to check the dependencies in the DLL on a computer where it wouldn't work, found two DLLs which come with the intel compiler that were needed, and distributed these with my own compiled DLL.

这篇关于在excel / fortran dll连接中遇到文件位置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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