• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

Static Library in COM

I have a Static Library (created in .net 2003 IDE) which exports a class whose constructors and desctructors are public.
Now, I have a COM created in VC++ 6.0  ATL Wiazrd and then compiling it using .net 2003.
Here, I am including my .lib file in my COM project and when I try to created object for the class defined in the library, am getting errors as given below:

PkCBls_Logging error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall PkCLogConfigData::~PkCLogConfigData(void)" (__imp_??1PkCLogConfigData@@QAE@XZ) referenced in function "public: virtual long __stdcall CLog::LoggingData(void)" (?LoggingData@CLog@@UAGJXZ)

PkCBls_Logging error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall PkCLogConfigData::PkCLogConfigData(void)" (__imp_??1PkCLogConfigData@@QAE@XZ) referenced in function "public: virtual long __stdcall CLog::LoggingData(void)" (?LoggingData@CLog@@UAGJXZ)

It shows that the constructor and destructor are not accessible by the COM.

However, I am using the same .lib files in a command line based project and am able to create objects and use it seamlessly

Thanks in advance.
0
Shenthilk
Asked:
Shenthilk
  • 3
  • 2
1 Solution
 
rcarlanCommented:
Do not use the __declspec(dllimport) on entities exported from a static library. There should be no storage-class modifiers for declarations exported by static libraries.
0
 
ShenthilkAuthor Commented:
If I remove the storage-class modifier, then I am getting the foll err:

PkCBls_Logging fatal error LNK1169: one or more multiply defined symbols found
PkCBls_Logging error LNK2005: _DllMain@12 already defined in PkCBls_Logging.obj

What does this mean?
0
 
rcarlanCommented:
Keep storage-class modifiers for declarations exported by the DLL.
Do not use storage-class modifiers for declarations exported by the static library.
0
 
rcarlanCommented:
Where is PkCBls_Logging.cpp: DLL or LIB?
0
 
ShenthilkAuthor Commented:
I have my problem solved. I have used the foll. syntax to create the object for the class defined in the static library

__declspec(dllimport) PkCLogConfigData            g_pkcConfigData;

PkCBls_Logging.cpp is the COM implementation file.

Thanks for ur help.

Shenthil
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now