Connection to COM object
-
How do I have to connect to COM object from a simple console application. The problem I have is like that: Client.obj : error LNK2001: unresolved external symbol _CLSID_IOConverter Client.obj : error LNK2001: unresolved external symbol _IID_IIOConverter Debug/Client.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. Client.exe - 3 error(s), 0 warning(s) My code: DEFINE_GUID(CLSID_IOConverter,...) DEFINE_GUID(CLSID_IOConverter,...) int main(int argc, char* argv[]) { CComPtr converter = NULL; CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); CoCreateInstance(CLSID_IOConverter,NULL, CLSCTX_INPROC_SERVER,IID_IIOConverter,(void**)&converter); CoUninitialize(); return 0; } What do I have to change?
-
How do I have to connect to COM object from a simple console application. The problem I have is like that: Client.obj : error LNK2001: unresolved external symbol _CLSID_IOConverter Client.obj : error LNK2001: unresolved external symbol _IID_IIOConverter Debug/Client.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. Client.exe - 3 error(s), 0 warning(s) My code: DEFINE_GUID(CLSID_IOConverter,...) DEFINE_GUID(CLSID_IOConverter,...) int main(int argc, char* argv[]) { CComPtr converter = NULL; CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); CoCreateInstance(CLSID_IOConverter,NULL, CLSCTX_INPROC_SERVER,IID_IIOConverter,(void**)&converter); CoUninitialize(); return 0; } What do I have to change?
There's only one error in the actual code. The CComPtr is a template class, and should be declared accordingly. Either you have forgotten the < and > signs or the forum is not displaying them. Anyway they should be there. The linker errors are generated because the GUIDs you define do not explicitly state the precise GUID numbers you wish to use. I couldn't find the IIOConverter interface definition from anywhere, so more than likely you have forgotten to link with the static library that defines these interfaces, or have forgotten to include a necessary header file. Check your settings. There doesn't seem to be other errors. If you need more help, you need to paste the entire DEFINE_GUID macros, and not just "..." as they might cause the errors as well. Also, you have not defined the IID_IIOConverter properly, thus the error. You can use
__uuidof( IIOConverter )
if you don't know the interface's GUID, but know the interface name. Also remember that in order to use the CComPtr class, include atlcomcli.h. To use CoInitializeEx, include objbase.h and link with ole32.lib. Remember that these are Platform SDK features, so you need to define the correct versioning macros as well. For more information, see MSDN with "Platform SDK, Using the Platform SDK" index word. Hope this helps -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.