Last Updated: February 25, 2016
·
897
· xavier007

A problem about QT

I encountered a problem about QT 。I want make a COM component by QT。I don't konw how to solve it。waiting for help。If U can give me a demo about how to make a COM component by QT,I will be very grateful。Of course, also like to thank all those who helped me
my email:xaviertonyyang@gmail.com

//32-50
//
HRESULT Calc::QueryInterface(const IID& iid, void** ppv)
{
if ( iid == IIDIUnknown )
{
ppv = (IUnknown *)this;
((IUnknown *)(
ppv))->AddRef();
} else if ( iid == IID
ICALC)
{
ppv = (IClassFactory *)this;
((ICalc *)(
ppv))->AddRef();
}
else
{
*ppv = NULL;
return E_NOINTERFACE ;
}

return S_OK;

}

//64-74

HRESULT ZFactory::CreateInstance(IUnknown pUnknownOuter,
const IID& iid, void *
ppv)
{
if(iid == IIDICALC || iid == IIDIUnknown)
{
ppv = new Calc();
(
(ICalc**)ppv)->AddRef();
}

return S_OK;

}
//121-136
void CLSIDtoString(const CLSID& clsid,
char* szCLSID,
int length)
{
assert(length >= CLSIDSTRINGSIZE) ;
// Get CLSID
LPOLESTR wszCLSID = NULL ;
HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;
assert(SUCCEEDED(hr)) ;

// Covert from wide characters to non-wide.
wcstombs(szCLSID, wszCLSID, length) ;

// Free memory.
CoTaskMemFree(wszCLSID) ;

}

debug/calc.o:H:\Mywebbrowser\xunfei\comdll/calc.cpp:34: undefined reference to IID_IUnknown' debug/registry.o: In functionZ13CLSIDtoStringRK5GUIDPci':
H:\Mywebbrowser\xunfei\comdll/registry.cpp:128: undefined reference to StringFromCLSID@8' H:\Mywebbrowser\xunfei\comdll/registry.cpp:135: undefined reference toCoTaskMemFree@4'
debug/zfactory.o:H:\Mywebbrowser\xunfei\comdll/zfactory.cpp:46: undefined reference to `IID
IUnknown'
debug/zfactory.o:H:\Mywebbrowser\xunfei\comdll/zfactory.cpp:50: undefined reference to IID_IClassFactory' debug/zfactory.o:H:\Mywebbrowser\xunfei\comdll/zfactory.cpp:67: undefined reference toIID_IUnknown'
collect2: ld returned 1 exit status