I am using gfortran compiler (under Simply Fortran) for Windows 64 and when creating a basic fortran dll for testing I cannot run it under VBA and got then runtime error 48 : the dll cannot be found.
here is my fortran subroutine code :
subroutine multiply(x, y, z)
!DEC$ ATTRIBUTES DLLEXPORT :: multiply
!DEC$ ATTRIBUTES ALIAS : "multiply" :: multiply
real, intent(in):: x, y
real, intent(out):: z
z = x * y
end subroutine multiply
I create the library typing : gfortran -shared -omultiply.dll multiply.f90 this library is located in "C:\Users\Olivier\Documents\Fortran\"
and my VBA code (I am using VBA 7.0) :
Declare Sub multiply Lib "C:\Users\Olivier\Documents\Fortran\multiply.dll" (x As Single, y As Single, ByRef z As Single)
Sub test()
Dim x As Single
Dim y As Single
Dim z As Single
x = 2
y = 3
Call multiply(x, y, z)
Cells(1, 1) = z
End Sub
When running this VBA code, it says it cannot find multiply.dll whereas this file is in the correct file mentioned in the declaration, if anyone could help please !
Thank you in advance