Creating A .dll With Gfortran

Dennis Wassel dennis.wassel@googlemail.com
Thu Jun 18 09:14:00 GMT 2009


Hi John,

please also include fortran@gcc.gnu.org in your answers.

> Thanks for that information, but I still haven't been able to get the .dll to run quite properly.  In other posts that I have seen online, I noticed that some compilers require a statement such as 'dll_Export GGGmain' in the subroutine which they want to pass.  Is there a similar command for Gfortran that I may be missing?  Thanks again for your time and help!

could you elaborate a bit more on the "run quite properly"?

gfortran currently does not support DLLEXPORT, STDCALL or similar
attributes (like ifort and some others do), but an enhancement request
exists that is considered useful by some developers:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34112
Feel free to add your 0.02$, but don't rely on this to be implemented
soon, since there seem to be one hell of a lot more urgent things to
do.

I for myself use a more sledgehammer-ish approach to building dlls. It
has the benefit of not having to worry about exports and such, because
it just exports *everything*. In terms of elegance, your approach
certainly is preferrable, but this has the benefit of It Just Works
(for me at least).

$(CC) -shared -Wl,--whole-archive $(MY_STATIC_LIB)
-Wl,--no-whole-archive $(DEPS) $(GFC_RTL)
-Wl,--out-implib=$(MY_IMP_LIB) -o $(MY_DLL)

You will probably still need to add the stdcall compiler options to
enable this dll to interface with VB.

Cheers,
Dennis



More information about the Fortran mailing list