Domanda

I have a DLL and a main executable, and the main executable is not linking in the symbols from the import library of the DLL anymore, and the declspec in the DLL .map file is not matching, nor is the mangled C++ name matching. I can't figure out why although I have done the usual things you do when you can't get C++ stuff to link.

My headers define something like this:

#ifdef MY_MODULE
#undef CLASS_EXPORT
#define CLASS_EXPORT __declspec(dllexport)
#else
#undef CLASS_EXPORT
#define CLASS_EXPORT __declspec(dllimport)
#endif

My classes seem to be exporting properly, but the .map file indicates some strange thing I think is wrong:

    6    ?CreateDataArea@@YAKPAGPBD111PAVCObject@@K@Z (unsigned long __cdecl 
    CreateDataArea(unsigned short *,char const *,char const *,char const *,
    char const *,class CObject *,unsigned long))

The mangled name above has @@YAK...

The link error is:

1>Device.obj : error LNK2019: unresolved external symbol 
"__declspec(dllimport) public: unsigned long __thiscall 
CCommonMemory::CreateDataArea(unsigned short *,char const *,char const *,
char const *,char const *,class CObject *,unsigned long)" 
(__imp_?CreateDataArea@CCommonMemory@@QAEKPAGPBD111PAVCObject@@K@Z) referenced 
in function "public: __thiscall CDevice::CDevice(void)" (??0CDevice@@QAE@XZ)

So why is the mangled name @@QAEK different when I have the declspec macro configured and why is the .map file showing __thiscall calling convention when the macro defines __declspec(dllexport)?

It's exactly like I forgot to do the __declspec(dllimport/dllexport) macro, yet I did it.

I tried putting CLASS_EXPORT on EACH method exported, and I tried it in the first line of the class declaration with no change.

È stato utile?

Soluzione

It looks like the definition for CreateDataArea() isn't being scoped to the class (ie., you've left off a CCommonMemory:: when defining the function).

If you look at what's getting into the map file, you'll see that it's a __cdecl function without the class name 'attached'.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top