I want to call a DLL from Delphi. But when I run my program Delphi gives an
error message saying "TEST.EXE is linked to MXREGEXP.DLL:RegComp that does
not exist."
What's wrong?
In Delphi RegComp( ) is declared like:
function RegComp(pPattern : PChar ) : longint ;
stdcall ; external 'mxregexp.dll' ;
The DLL is created with C++Builder 3.0. I have checked that function
RegComp() really is exported and the def-file look like this:
--- start
LIBRARY MXREGEXP.DLL
EXPORTS
@Classes@TList@$bctr$qqrv @1 ; Classes::TList::TList() __fastcall
@RegComp$qqspc @2 ; RegComp(char*) __stdcall
--- end
Please help, someone!
Thanks!
/Anders Sundberg
Ivan Detkov
Zedak Corp.
Andy Sandberg wrote in message <6lh642$57...@forums.borland.com>...
If you change your definition to something like the following:
extern "C" long int __declspec(dllexport) RegComp(char*);
You should be able to load the function in Delphi at the expense of
adding an underscore to the pascal defininition (e.g., _Regcomp);
I'm a little new to C++Builder, so this isn't a perfect solution,
since I haven't figured out a way to get the dll to compile without
adding the underscore, but hopefully this helps you out.
On Mon, 8 Jun 1998 19:15:27 +0200, "Andy Sandberg" <sum...@tripnet.se>
wrote:
It worked!
/Andy
Ivan Detkov wrote in message <6lh7n9$4n...@forums.borland.com>...
>The name of the function is @RegComp$qqspc. It is better to use dynamic dll
>loading (look at LoadLibrary function.) Other possibility is unmangle name
>of the function. I believe that extern "C" function declaration in dll can
>do it for you.
>
>Ivan Detkov
>Zedak Corp.
>
>Andy Sandberg wrote in message <6lh642$57...@forums.borland.com>...
Peter Below (TeamB) 10011...@compuserve.com)
As I stated, I am new to C++Builder and was relying on the help
documentation, which states that, "__fastcall and _ _stdcall are
always name mangled in C++". Is this a documentation error?
Regards,
Brian
P.S. At the risk of being accused of cross-posting, do you happen to
know how to get the linker to drop those pesky underscores?
there are two kinds of mangling here, the one C++ does if you do not specify
extern "C", which encodes parameter number and type, and the one that happens
for stdcall even with extern "C": an appended @<n> where <n> is the number of
bytes the parameters occupy on the stack.
> P.S. At the risk of being accused of cross-posting, do you happen to
> know how to get the linker to drop those pesky underscores?
You can eliminate any kind of mangling by using a DEF file instead of
(or in addition to) _declspec. In the DEF file you can explicitely give the
name you want exported.
Peter Below (TeamB) 10011...@compuserve.com)
>You can eliminate any kind of mangling by using a DEF file instead of
>(or in addition to) _declspec. In the DEF file you can explicitely give the
>name you want exported.
Thanks for the info as well as for the clarification on name mangling.
Regards,
Brian