I'm calling a Fortran DLL from C# code. All works fines for the code shown below and I well receive the correct return value at my C# side.
However, as soon as I uncomment the line open(31, file='output.txt', status='new')
, I get the following exception:
System.DllNotFoundException: 'Unable to load DLL 'MyProgram.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'
Same result for all calls I try to make to the Fortran read()
and write()
functions.
For info; I'm compiling with gfortran
installed via mingw-w64
.
function return_integer(input) result(output)
! Don't leave the calling convention to chance.
!GCC$ ATTRIBUTES CDECL :: return_integer
integer*4, intent(in) :: input
integer*4 :: output
! open(31, file='output.txt', status='new' )
output = 2*input+1
end function
User contributions licensed under CC BY-SA 3.0