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. How can I call COM from MakeFile Project in C++

How can I call COM from MakeFile Project in C++

Scheduled Pinned Locked Moved C / C++ / MFC
comhelpc++questionannouncement
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.
  • A Offline
    A Offline
    ashok123
    wrote on last edited by
    #1

    Hi All, I have a makefile project and I want to call COM (ActiveX control) in the project. The code to call COM in makefile is as follows: Files included for COM support are: #include #include #include #include #include //I am just putting the COM calling code let me know if I m doing the right way. HRESULT hr = CoInitialize(NULL); if(FAILED(hr)) { printf("CoInitialize Failed\n"); return 0; } IMyInterface* pInt = NULL; hr = CoCreateInstance(CLSID_MyInterface, NULL, CLSCTX_INPROC_SERVER, IID_IMyInterface, reinterpret_cast (&pInt)); if(SUCCEEDED(hr)) pInt->Connect(); //This is the COM funtion that I want to use pInt->Release(); CoUninitialize(); It compiles fine but when I try to build it gives me Linking Error... MyClass.OBJ : error LNK2001: unresolved external symbol __imp__CoUninitialize@0 MyClass.OBJ : error LNK2001: unresolved external symbol __imp__CoCreateInstance@20 MyClass.OBJ : error LNK2001: unresolved external symbol __imp__CoInitialize@4 MyApplication.EXE : fatal error LNK1120: 3 unresolved externals NMAKE : fatal error U1077: 'link' : return code '0x460' Please help me on this. Thanks in advance. Ashok

    D 1 Reply Last reply
    0
    • A ashok123

      Hi All, I have a makefile project and I want to call COM (ActiveX control) in the project. The code to call COM in makefile is as follows: Files included for COM support are: #include #include #include #include #include //I am just putting the COM calling code let me know if I m doing the right way. HRESULT hr = CoInitialize(NULL); if(FAILED(hr)) { printf("CoInitialize Failed\n"); return 0; } IMyInterface* pInt = NULL; hr = CoCreateInstance(CLSID_MyInterface, NULL, CLSCTX_INPROC_SERVER, IID_IMyInterface, reinterpret_cast (&pInt)); if(SUCCEEDED(hr)) pInt->Connect(); //This is the COM funtion that I want to use pInt->Release(); CoUninitialize(); It compiles fine but when I try to build it gives me Linking Error... MyClass.OBJ : error LNK2001: unresolved external symbol __imp__CoUninitialize@0 MyClass.OBJ : error LNK2001: unresolved external symbol __imp__CoCreateInstance@20 MyClass.OBJ : error LNK2001: unresolved external symbol __imp__CoInitialize@4 MyApplication.EXE : fatal error LNK1120: 3 unresolved externals NMAKE : fatal error U1077: 'link' : return code '0x460' Please help me on this. Thanks in advance. Ashok

      D Offline
      D Offline
      douglasjordan
      wrote on last edited by
      #2

      Sounds like you need to add ole32.lib to the project's lib files.

      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