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.
CLSID_StockObjectManager, so yes you should#include "Stock_i.c", but only in one cpp per project. It's true that c filea should not be#included in general. But COM interface generated c file (..._i.c) with the classid is one exception.