Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Connection to COM object

Connection to COM object

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestioncomdebugging
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dudic
    wrote on last edited by
    #1

    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?

    A 1 Reply Last reply
    0
    • D dudic

      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?

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups