Board index » cppbuilder » VC++ dll Impdef/implib problem

VC++ dll Impdef/implib problem

Help!

I know to use Impdef on a MS dll to create a def file and then to use
Implib on the def file to create an import lib, but in this case I am
having a problem. The exported functions are methods of a class and I
have no idea how to create an alias for them. Also, in the def file, all
the functions are prepended with a "?" which implib reports as an
illegal symbol. For example (in the def file):
////////////////////////////////////
LIBRARY     CONTINUUMCLIENT.DLL

EXPORTS
    ?BuildDemoFile@ContinuumClient@@QAEXPBD@Z @1  
    ?CheckPermission@ContinuumClient@@QAEEPBD@Z @2  
    ?CheckSymbolStatus@ContinuumClient@@QAEFPBD@Z @3  
    ?Connect@ContinuumClient@@QAEDPBD0K@Z @4  
    ?Connect@ContinuumClient@@QAE_NPAUHWND__@@@Z @5  
    ?Connect@ContinuumClient@@QAE_NPAVEConnectStatus@@@Z @6
...//partial list  
////////////////////////////////

where all these are member functions the class ContinuumClient.

If it helps, the header looks like this:

////////////////////////////

#ifndef ContinuumClient_H
#define ContinuumClient_H

#undef INTERFACE
#ifdef CONTINUUMCLIENT_DLL
#define INTERFACE __declspec(dllexport)
#else
#define INTERFACE __declspec(dllimport)
#endif

class ContinuumClient {
protected:
public:
                                        ContinuumClient();
                                   ~ContinuumClient();
  INTERFACE bool        Connect(HWND hwnd);
  INTERFACE bool        Connect(EConnectStatus* pCS);
  INTERFACE char    Connect(LPCSTR pszName,LPCSTR pszPswd,DWORD dwWait);
  INTERFACE LPCSTR  GetUserName();
  INTERFACE LPCSTR  GetUserPswd(bool bEncrypted);
  INTERFACE void        Disconnect();
  INTERFACE void        NextServer();
  INTERFACE void        Shutdown();

...//partial list

////////////////////////////////////////////////////////////////////

So, how would I create aliases for the exported class methods in the def
file so that I can create an import lib? Any other suggestions?

Thanks in advance for any and all help.

Brett

 

Re:VC++ dll Impdef/implib problem


You cannot do what you are attempting to do when C++ classes are
involved. Even if you were able to make everything link it still
wouldn't work properly. If you need to share classes between VC and BCB
they need to be pure virtual interfaces with a C functions being
exported to create an object. I know I posted something that answers
this question in more detail a few days ago so perhaps a search would
prove fruitful. It is also a common enough question I'm sure others have
answered it.

If you want more of an answer than "don't do that it will not work" I'd
suggest a visit to www.dejanews.com to do a search.

Anduin Withers
borland.com

Quote
exmi...@banet.net wrote:

> Help!

> I know to use Impdef on a MS dll to create a def file and then to use
> Implib on the def file to create an import lib, but in this case I am
> having a problem. The exported functions are methods of a class and I
> have no idea how to create an alias for them. Also, in the def file, all
> the functions are prepended with a "?" which implib reports as an
> illegal symbol. For example (in the def file):
> ////////////////////////////////////
> LIBRARY     CONTINUUMCLIENT.DLL

> EXPORTS
>     ?BuildDemoFile@ContinuumClient@@QAEXPBD@Z @1
>     ?CheckPermission@ContinuumClient@@QAEEPBD@Z @2
>     ?CheckSymbolStatus@ContinuumClient@@QAEFPBD@Z @3
>     ?Connect@ContinuumClient@@QAEDPBD0K@Z @4
>     ?Connect@ContinuumClient@@QAE_NPAUHWND__@@@Z @5
>     ?Connect@ContinuumClient@@QAE_NPAVEConnectStatus@@@Z @6
> ...//partial list
> ////////////////////////////////

> where all these are member functions the class ContinuumClient.

> If it helps, the header looks like this:

> ////////////////////////////

> #ifndef ContinuumClient_H
> #define ContinuumClient_H

> #undef INTERFACE
> #ifdef CONTINUUMCLIENT_DLL
> #define INTERFACE __declspec(dllexport)
> #else
> #define INTERFACE __declspec(dllimport)
> #endif

> class ContinuumClient {
> protected:
> public:
>                                         ContinuumClient();
>                                    ~ContinuumClient();
>   INTERFACE bool        Connect(HWND hwnd);
>   INTERFACE bool        Connect(EConnectStatus* pCS);
>   INTERFACE char    Connect(LPCSTR pszName,LPCSTR pszPswd,DWORD dwWait);
>   INTERFACE LPCSTR  GetUserName();
>   INTERFACE LPCSTR  GetUserPswd(bool bEncrypted);
>   INTERFACE void        Disconnect();
>   INTERFACE void        NextServer();
>   INTERFACE void        Shutdown();

> ...//partial list

> ////////////////////////////////////////////////////////////////////

> So, how would I create aliases for the exported class methods in the def
> file so that I can create an import lib? Any other suggestions?

> Thanks in advance for any and all help.

> Brett

Re:VC++ dll Impdef/implib problem


Quote
Anduin Withers wrote:

It is also a common enough question I'm sure others have

Quote
> answered it.

> If you want more of an answer than "don't do that it will not work" I'd
> suggest a visit to www.dejanews.com to do a search.

Thanks for the suggestion, but I have been searching the newsgroups for
the last two days with few results regarding exported class methods.

Brett

Re:VC++ dll Impdef/implib problem


Try going to www.dejanews.com and searching for the following:

borland.public.cppbuilder.language anduin virtual

You can find most of the thread there.

Anduin Withers
borland.com

Quote
exmi...@banet.net wrote:

> Anduin Withers wrote:
> It is also a common enough question I'm sure others have
> > answered it.

> > If you want more of an answer than "don't do that it will not work" I'd
> > suggest a visit to www.dejanews.com to do a search.

> Thanks for the suggestion, but I have been searching the newsgroups for
> the last two days with few results regarding exported class methods.

> Brett

Other Threads