Using CALL_EXTERNAL with C++ Code [message #37856] |
Thu, 29 January 2004 05:49  |
ebertf
Messages: 12 Registered: January 2004
|
Junior Member |
|
|
Hello,
I have a problem compiling and linking a DLL in C++ and integrate it
into IDL via CALL External. Everything works fine with C in this way
using a wrapper function:
-------------------------------------------------
C-Code of wrapper function:
#include "stdio.h"
#include "idl_export.h"
#include "myDLL.h"
_declspec(dllexport) IDL_INT IDL_CDECL mydllquest(int argc, void
*argv[])
{
return (dllquest(((IDL_INT) argv[0])));
}
----------------------------------------------------
compiling and linking were done from the DOS Console (VC6 is
installed):
cl -DLL -DWIN32 -D_MT /nologo /I"C:\RSI\IDL60\external\include" /c
mydllglue.c /Fomydllglue.obj
link /out:mydllglue.dll /nologo /nodefaultlib /dll mydllglue.obj
"C:\RSI\IDL60\bin\bin.x86\idl32.lib" dll.lib msvcrt.lib kernel32.lib
-------------------------------------------------------
The call in IDL works like this:
res=call_external(<path of
mydllglue.dll>,'mydllquest',1,/cdecl,value=[0])
---------------------------------------------------------
Compiling with C is working fine, but when the ending of the wrapper
file is *.cpp or if you use the option /Tp (means: compile this as
C++) then IDL is causing an error.
Can anybody give me a hint, what could be wrong or need to changed
when switching to c++?
Florian
|
|
|
Re: Using CALL_EXTERNAL with C++ Code [message #37874 is a reply to message #37856] |
Tue, 03 February 2004 20:08  |
the_cacc
Messages: 104 Registered: October 2001
|
Senior Member |
|
|
ebertf@gmx.de (Florian Meyer) wrote in message news:<14e53261.0402030142.1a7147a8@posting.google.com>...
> I got a solution for my problem. For anyone, who might be interested:
> When using the C++ Compiler the names in the EXPORT LIST are decorated
> with funny tags.
>
> An example:
> An entry in your DLL, lookin like this:
>
> _declspec(dllexport) IDL_INT IDL_CDECL dllquest(int argc, void
> *argv[])
> {
> <your C++ code>
> }
>
> is causing a name in the exportlist like this:
>
> ?dllquest@@YAFHQAPAX@Z
>
> With CALL_EXTERNAL you need to call the second one, then it works and
> you can process C++ Code in IDL. Using C-Compiler (option /Tc with cl)
> the names are equal.
> How the the Compiler changed the names can be obtained with a command
> from the DOS Prompt on the OBJECT File the compiler created:
>
> DUMPBIN <*.obj-File> /SYMBOLS
>
> There you can find both names.
>
> I think there are other ways to work around this problem (not to call
> this weired decorated names) with a *.def File. But I don�t know how
> to do that. If anybody can give a little 'manual' how to create such a
> DLL I were very grateful.
>
> Florian
I'm not clear whether you've "solved" the problem or merely hacked in
the weird function names in place of the ones you expected.
A less evil hack is compiling with the /TC flag (NB. not /Tc - that's
different). It may mean you can't overload your functions though,
since C++ uses the extra tags to specify argument types so functions
you give the same name are (internally by C++) given different names.
|
|
|