creating dll to link with delphi program
Brad Finney
Brad.Finney@humboldt.edu
Tue Nov 15 15:50:00 GMT 2011
On 11/15/2011 2:40 AM, Tobias Burnus wrote:
> Dear Brad,
>
> On 10/24/2011 09:00 PM,
>>> The leading _ is added there because the ABI (application binary
>>> interface) of 32bit Windows *requires* it. If you don't like it, blame
>>> Microsoft.
>
> There seems to be an additional detail, which I had overlooked: For
> symbols in DLLs, there seem to be different rules. - And Delphi seems to
> have use some extra convention in addition.
>
> To quote Danny: "DLLs built with MS-Windows tools use different default
> rules for the naming of __stdcall function names in export table: for
> stdcall symbols the string in the dll's export table has the assembler
> prefix '_' prepended, while for cdecl symbols or variable names, the
> underscore prefix is stripped. In contrast, in dlls built with GNU
> tools, the assembler underscore prefix is stripped from all symbols by
> default."
> From: http://cygwin.com/ml/binutils/2006-03/msg00086.html
>
> Searching different webpages, I have not really found a really helpful
> explanation or rules. When generating a DLL, one can (cf. link above)
> modify the mangling either by flags or by the .def file.
>
> For interaction with DLLs, you might also want to use
> DLLEXPORT/DLLIMPORT, though those do not seem to change the mangling.
> (dllimport of "foo" imports __imp__foo (cdecl) or __imp__foo@0
> (stdcall); dllexport has _foo and _foo@0). Though, as written, when
> linking one can modify the mangling by the dlltools/linker.
>
> In any case, "underscore DLL prefix" (and variants) will turn up
> hundreds of web pages, where people have similar issues - independent of
> the compiler.
>
> See also:
> http://mirrors.zoreil.com/webclub.kcom.ne.jp/ma/colinp/win32/dll/make.html
> and http://www.willus.com/mingw/yongweiwu_stdcall.html
>
> Tobias,
> who is rather confused and praises the Win64 and Unix (default) calling
> conventions.
>
Thanks for the additional information Tobias. I am not usually stopped
on a project like this, but I had completely run out of ideas/options to
get a gfortran .dll library with a symbol naming convention that agrees
with what the delphi executable is looking for. I will pursue the links
you identified further and report back any success I have.
Brad
More information about the Fortran
mailing list