Loading...

fortran@gcc.gnu.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: creating dll to link with delphi program Tobias Burnus Fri Oct 28 05:00:23 2011

Brad Finney wrote:
SUBROUTINE PrintOutX(x)
!GCC$ ATTRIBUTES DLLEXPORT::PrintOutX
 write(*,*)x
END SUBROUTINE PrintOutX

if I use
gfortran -c -fno-leading-underscore -fno-underscoring testcase.f90

The object file contains -export:"printoutx" which does not preserve the case of the requested export name.

In gfortran - contrary to ifort -, you have to use C binding, cf. http://gcc.gnu.org/onlinedocs/gfortran/Mixed_002dLanguage-Programming.html

SUBROUTINE PrintOutX(x) bind(c, name="PrintOutX")
!GCC$ ATTRIBUTES DLLEXPORT::PrintOutX
use iso_c_binding
real(c_float) x
write(*,*) x
end


That should work without special options. Note: Depending on the caller, you might need to add "stdcall" - but the default "cdecl" could also be correct.

Tobias