please help - can't link to a DLL with gfortran

Craig Powers enigma@hal-pc.org
Sat Dec 6 19:52:00 GMT 2008


David Gittins wrote:
> Hi,
> 
>> Such mangling usually means, that function uses stdcall 
>> calling convention
> 
>> See above, this is not just 'naming issue'.
> 
> OK, I believe you.
> 
> In which case I am even more confused. CVF managed to figure out, without
> any additional information, that these unresolved functions should use
> stdcall, and matched them up with the lib.

It's not that simple.  Assuming there's no CVF-specific set of 
interfaces for netcdf, the reason CVF "managed to figure out" because 
the default calling convention for CVF is stdcall.  To call into a 
library containing cdecl functions in CVF, you would need to have 
explicit interfaces for them that identified the calling convention as 
cdecl.

> If this were some C code, I could modify the external function declarations
> to tell the compiler that they are stdcall, right? But in fortran, my
> declaration is just 'external'. Is there no way to tell the compiler to use
> stdcall convention for them?

There's no universally-recognized extension.  The 
Intel/Compaq/Digital/MS line of compilers has comment directives that 
offer control over the calling convention of a particular function.

> But suppose I did recompile netcdf with gcc (the source is in C I think).
> Presumably, the result would still be a library expecting its functions to
> be called using stdcall.

I would not make that presumption.  In fact, I would sooner expect gcc 
to produce a library with everything as cdecl, and even if it didn't do 
that by default, I strongly suspect you could alter the configuration to 
make it do so.



More information about the Fortran mailing list