How can I call COM from MakeFile Project in C++
-
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
-
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
Sounds like you need to add ole32.lib to the project's lib files.