www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Question about DLLs & implib

reply John Kiro <johnkirollos yahoo.com> writes:
Hi There

I have a DLL containing functions having stdcall calling convention.
In order to be able to call these functions from inside a D-language
program, I tried to create an import lib for the DLL using implib.exe.
But the problem is that implib.exe neglects the calling convention of
the functions, i.e. doesn't take into account the name decoration, so
the linker does not find them.

The only solution I see is to use the "C" calling convention instead,
and use the option /s (or /system) with implib.exe:

   implib.exe /system mydll.lib mydll.dll

So is there a way to use the stdcall convention instead?

Thanks in advance
john
Jan 29 2007
next sibling parent reply Mike Parker <aldacron71 yahoo.com> writes:
John Kiro wrote:
 Hi There
 
 I have a DLL containing functions having stdcall calling convention.
 In order to be able to call these functions from inside a D-language
 program, I tried to create an import lib for the DLL using implib.exe.
 But the problem is that implib.exe neglects the calling convention of
 the functions, i.e. doesn't take into account the name decoration, so
 the linker does not find them.
 
 The only solution I see is to use the "C" calling convention instead,
 and use the option /s (or /system) with implib.exe:
 
    implib.exe /system mydll.lib mydll.dll
 
 So is there a way to use the stdcall convention instead?
 

extern(Windows)
Jan 30 2007
parent John Kiro <johnkirollos yahoo.com> writes:
I'm using "extern(Windows)" already.
Jan 30 2007
prev sibling parent Carlos Santander <csantander619 gmail.com> writes:
John Kiro escribió:
 Hi There
 
 I have a DLL containing functions having stdcall calling convention.
 In order to be able to call these functions from inside a D-language
 program, I tried to create an import lib for the DLL using implib.exe.
 But the problem is that implib.exe neglects the calling convention of
 the functions, i.e. doesn't take into account the name decoration, so
 the linker does not find them.
 
 The only solution I see is to use the "C" calling convention instead,
 and use the option /s (or /system) with implib.exe:
 
    implib.exe /system mydll.lib mydll.dll
 
 So is there a way to use the stdcall convention instead?
 
 Thanks in advance
 john

If you're talking about DLLs that come with Windows, I remember some of the symbols would be stdcall and others would be C (even in the same DLL), so that might be the case with you right now. Maybe you can use "lib -l" (IIRC) to check how each name is mangled? -- Carlos Santander Bernal
Jan 31 2007