Re: c calling a fortran subroutine

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



RichN wrote:
> hi Carl,
>
> I am able, now, to run dumpbin at my PC. In any case, I ran /EXPORTS,
> and got the following:
>
> Dump of file sftck3.lib
> File Type: LIBRARY
> Exports
> ordinal name
> _SFTCK3
>
> Summary
> C3 .debug$S
> 14 .idata$2
> 14 .idata$3
> 4 .idata$4
> 4 .idata$5
> C .idata$6
>
> I checked this against a known working DLL I previously created in C,
> and the output
> is similar. So now I'm thinking that the subroutine name is there,
> but that the original error "unresolved external symbol _SFTCK3@0" is
> indicating the function name is undefined to the function that is
> calling it. Normally, in C, I would have some kind of #include
> "xxxxxxxx" to define SFTCK3. Do I need some type of .h to go with my
> fortran dll?

OK, so your C code is expecting a function with the normal __stdcall name
decorations (_name@paramSize), while your Fortran DLL exported only a simple
name.

Are you sure that the Fortran code is __stdcall? It's named as if it's
__cdecl. Try changing your extern declaration in the C module to use
__cdecl. That'll probably make it link - if the Fortran function doesn't
actually __cdecl, then the mismatch will likely cause the program to crash
shortly after returning from the Fortran sub.

-cd


.



Relevant Pages

  • Re: module
    ... Without -mrtd, the default is CDECL, with -mrtd ... All functions and (Fortran) procedures without ... stdcall. ... In math.h, acos is declared as: ...
    (comp.lang.fortran)
  • Re: c calling a fortran subroutine
    ... while your Fortran DLL exported only a simple ... > Are you sure that the Fortran code is __stdcall? ... > __cdecl. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: StdCall vs. CDecl
    ... why is StdCall the default if it's usually incorrect? ... We have a bunch of DLLs that all use CDecl because that's the default that Visual Studio gives us. ... We also have a bunch of Ada and FORTRAN code that calls into those libraries, probably using StdCall semantics (none of our code in either language uses any keywords to specify the calling convention, so I would hope that they choose StdCall by default). ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Trouble linking FORTRAN DLL with C++ application (undefined reference)
    ... | I created a FORTRAN DLL with Digital Visual Fortran 6.0 and have been ... | trouble with the getting the calling conventions right. ...
    (comp.lang.fortran)
  • Re: mixed language programming - LNK2001
    ... maybe the name of your external procedure is not maximum, but maximum@8, as the error message says. ... This is the stdcall style decoration of the name. ... Beside I see a second problem: The fortran code defines maximum as a subroutine with one integer argument, as the c function needs two; so the stack will be corrupted running this program. ...
    (comp.lang.fortran)