creating dll to link with delphi program

Tobias Burnus burnus@net-b.de
Sun Oct 23 14:19:00 GMT 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



More information about the Fortran mailing list