I have 2 DLLs. I want create instance of class in my second DLL that I declare at .idl file of first library. But I get Error Link 2001 on CLSID, when try to link second DLL. I'm linking with first DLL, so I don't know why I'm getting this error.
Stock.idl
Declaration of class
[uuid(61AF2A3E-8B04-4161-B978-5776BFDF7DB5), helpstring("StockObjectManager Class")]
coclass StockObjectManager
{
[default] interface IStockObjectManager;
interface ISQLBase;
};
Generated Files:
Stock.h
EXTERN_C const CLSID CLSID_MazStockObjectManager;
Stock_i.c
MIDL_DEFINE_GUID(CLSID, CLSID_StockObjectManager,0x61AF2A3E,0x8B04,0x4161,0xB9,0x78,0x57,0x76,0xBF,0xDF,0x7D,0xB5);
FIleFromSecondDll.cpp
CComPtr<IStockObjectManager> m_SOManager;
m_SOManager.CoCreateInstance(CLSID_StockObjectManager); // getting Error Link 2001 unresolved external symbol "_CLSID_StockObjectManager"
I want to understand why I'm getting this error and fix it. Of course, I can just #include "Stock_i.c"
, but it isn't good solution, I guess.
in Stock.h must be not only
EXTERN_C const CLSID CLSID_MazStockObjectManager;
but also
#ifdef __cplusplus
class DECLSPEC_UUID("61AF2A3E-8B04-4161-B978-5776BFDF7DB5") MazStockObjectManager;
#endif
so and use
CComPtr<IStockObjectManager> m_SOManager;
m_SOManager.CoCreateInstance(__uuidof(MazStockObjectManager));