Hello All,
I know this is not really a new topic - but I'm new to Fortran and lost in the bits and pieces I've found regarding the creation of a DLL usable from another program (for example LabVIEW, Visual Basic, C, etc).
For myself, I plan to use LabVIEW to call some existing Fortran code that does some really neat Mie Scattering calculations.
LabVIEW can use C or STDCALL conventions.
I’m use the newest version of gfortran as my compiler
To explore how to do this I wrote a simple program:
Example.f
subroutine Sub1 (A,B,C)
implicit none
Real*8 A,B,C
call Sub2 (A,B,C)
print*,C
end
subroutine Sub2 (A2,B2,C2)
implicit none
Real*8 A2,B2,C2
C2=A2+B2
end
I only really need to make “Sub1” available to the outside world. I believe there are two things I need to get right for everyone to be happy - define calling convention and limit name-mangling – for example:
1)Put somewhere in my program (and correctly use)
a) !GCC$ ATTRIBUTES attribute-list :: variable-list (including STDCALL)
b) DLLEXPORT (if needed)
2)Specify the correct command line options for gfortran compilation
e.g. gfortran –shared –o example.dll example.f
For whatever reason I’m not having much luck finding documentation that clearly states how to use these commands/modifiers…ho hum….
Anyway, all help is very much appreciated!
Cheers,
-Jeff
I know this is not really a new topic - but I'm new to Fortran and lost in the bits and pieces I've found regarding the creation of a DLL usable from another program (for example LabVIEW, Visual Basic, C, etc).
For myself, I plan to use LabVIEW to call some existing Fortran code that does some really neat Mie Scattering calculations.
LabVIEW can use C or STDCALL conventions.
I’m use the newest version of gfortran as my compiler
To explore how to do this I wrote a simple program:
Example.f
subroutine Sub1 (A,B,C)
implicit none
Real*8 A,B,C
call Sub2 (A,B,C)
print*,C
end
subroutine Sub2 (A2,B2,C2)
implicit none
Real*8 A2,B2,C2
C2=A2+B2
end
I only really need to make “Sub1” available to the outside world. I believe there are two things I need to get right for everyone to be happy - define calling convention and limit name-mangling – for example:
1)Put somewhere in my program (and correctly use)
a) !GCC$ ATTRIBUTES attribute-list :: variable-list (including STDCALL)
b) DLLEXPORT (if needed)
2)Specify the correct command line options for gfortran compilation
e.g. gfortran –shared –o example.dll example.f
For whatever reason I’m not having much luck finding documentation that clearly states how to use these commands/modifiers…ho hum….
Anyway, all help is very much appreciated!
Cheers,
-Jeff