I have developed a DLL using Delphi. But to call the functions in that
DLL from a Visual C++ application, using IMPLICIT linking (i.e., making
an import library and linking with it) makes problems. I have created an
import library with Microsoft LIB /DEF<MYDEFFILENAME.DEF>
But the Visual C++ compiler mangles the name of function..
e.g. My function Name is
function DisplayStatus:Integer; stdcall; in delphi DLL.
I have given its prototype in VCPP application as
extern "C" int APIENTRY DisplayStatus();
But the VCPP compiler mangles the name as _DisplayStatus@0, which is not
there in the DLL. So the linker gives error. If I try with
GetProcAddress it is OKAY. But I have to do it with IMPORT LIB . Pleae
help me back at joj...@hotmail.com
>I have developed a DLL using Delphi. But to call the functions in that
>DLL from a Visual C++ application, using IMPLICIT linking (i.e., making
>an import library and linking with it) makes problems. I have created an
>import library with Microsoft LIB /DEF<MYDEFFILENAME.DEF>
>But the Visual C++ compiler mangles the name of function..
There has to be a way to make VC++ emit non-decorated function names;
otherwise, a VC++ application couldn't call any of the Windows API
functions. Unfortunately, I don't use VC++ and don't know what you
have to do.
As a short-term fix, you can export the Delphi functions with
decorated names:
exports
Foo name 'Foo@0',
Bar name 'Bar@12';
-Steve
Just a guess, but add stdcall to the above VC++ prototype. That should tell
VC++ to not mangle the names.
--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev -- Amazon.com Associate
at http://home.ican.net/~wniddery/RADBooks.html
...remove chaff when replying...
>Just a guess, but add stdcall to the above VC++ prototype. That should tell
>VC++ to not mangle the names.
That, unfortunately, is not enough. I recently had an extensive
back-and-forth with a developer over the exported function names in a
DLL that he had written, and we never did figure out how to get VC++
to refrain from appending the @XXX, even though all of the functions
were indeed stdcall.
-Steve
B Banerjee wrote:
> Hi Anybody Help me!
>
> I have developed a DLL using Delphi. But to call the functions in that
> DLL from a Visual C++ application, using IMPLICIT linking (i.e., making
> an import library and linking with it) makes problems. I have created an
> import library with Microsoft LIB /DEF<MYDEFFILENAME.DEF>
> But the Visual C++ compiler mangles the name of function..
> e.g. My function Name is
>
> function DisplayStatus:Integer; stdcall; in delphi DLL.
>
> I have given its prototype in VCPP application as
>
> extern "C" int APIENTRY DisplayStatus();
>
Armin
Krasimir Stoyanov schrieb in Nachricht <360180B8...@internet-bg.bg>...
You actually have to create the DLL in VC (well, almost)!
Implement all your exported prototypes in VC with empty bodies. Then put the
function names in a DEF file below the EXPORTS keyword. When you build the
project VC will create a new DLL for you (just ignore it) and more
important, an import library that "maps" the mangled names to the correct
exported names in the Delphi DLL.
This is also explained in a MS knowledge base article.
--
Sebastian Bargmann
Remove NOSPAM etc...
delphi calls:
function blah(x : integer): integer; cdecl; external 'blah.dll';
C++ function:
extern "C" _declspec(dllexport) int blah(int x){
return x;
}
the "C" tells it to maintain standard names, the _declspec tells it which
convention and tells it to export... I think you could use _stdcall(dllexport)
too, but don't have delphi here to test it.
Hope this helps...
--Jacob Thurman