Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

DLL Excel Read Write ERROR

jhjensen
Beginner
772 Views
Hello
Changing fro Digital Visual Fortran and from Win XP to Win 7 cause me a great probelm with a DLL that i use from Excel.
The Dll works on my PC but not on a target PC (where ordinary programs works ok)
The error read "Run time error '48': File not found c:\\testfortran\\Dll1.dll"
The file IS there, I suspect a missing DLL but is not able to locate the sinner.
Here is the Fortran code:

integer function TestRW(cdum)
c
!DEC$ ATTRIBUTES STDCALL::TestRW
!DEC$ ATTRIBUTES REFERENCE::Cdum
!DEC$ ATTRIBUTES DLLEXPORT::TestRW
!DEC$ ATTRIBUTES ALIAS:'TestRW' ::TestRW
real cdum
open(unit=55,file='c:\\testfortran\\out.txt')
write(55,10) 'Hello world'
10 format(1x,a)
close(55)
TestRW=1
end

And the VBA code:
Declare Function TestRW Lib "c:\\testfortran\\Dll1.dll" _
(ByRef cd As Single) As Long
Sub Test_til_Excel()
Dim cd As Single, ret As Long
cd = 0
ret = TestRW(cd)
ret = 0
End Sub

As far as I can tell, the error occures when including the read/write statements.
Please advice and save my day

Regards
J H Jensen

0 Kudos
1 Solution
Steven_L_Intel1
Employee
772 Views
If your DLL is built with Intel Fortran, you need the Intel Fortran and Microsoft Visual C++ run-time DLLs on the target system. While you can install these, for the case where the DLL is being called from outside Fortran I suggest the easier approach is to change the Fortran project property Fortran > Libraries > Use Runtime Library to "Multithreaded (/MT)". This will remove dependencies on those DLLs. I don't recommend this approach if the Fortran DLL is being called by a Fortran executable.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
773 Views
If your DLL is built with Intel Fortran, you need the Intel Fortran and Microsoft Visual C++ run-time DLLs on the target system. While you can install these, for the case where the DLL is being called from outside Fortran I suggest the easier approach is to change the Fortran project property Fortran > Libraries > Use Runtime Library to "Multithreaded (/MT)". This will remove dependencies on those DLLs. I don't recommend this approach if the Fortran DLL is being called by a Fortran executable.
0 Kudos
jhjensen
Beginner
772 Views

Steve, thank you!
As always, right on the spot and correct.
I realy admire your long and outstanding workanswering questions about FORTRAN
Regard
J H Jensen

0 Kudos
Reply