Friday, June 22, 2018

c++ - Unresolved external symbol _IID / _CLSID



I created a default ATL project with MSVC 2010 with a simple default ATL dialog. Then I added the second project into solution, named MyControls, where I created ATL DHTML Control with a help of Wizard. Then I placed ATL DHTML Control to ATL dialog.



Now I would like to call some methods of that ATL DHTML Control in ATL dialog's OnInitDialog function. In order to be able to make a call like:



CComPtr ptr;
HRESULT hr = GetDlgControl(IDC_ACTIVEX_CONTROL_DHTML
, IID_IDHTMLControl, (void**)&ptr);



I am including the file DHTMLControl.h from MyControls project. However, I get the following errors:




  • Error 1 error LNK2001: unresolved external symbol _IID_IDHTMLControl

  • Error 2 error LNK2001: unresolved external symbol _LIBID_MyControlsLib

  • Error 3 error LNK2001: unresolved external symbol _CLSID_DHTMLControl

  • Error 4 error LNK2001: unresolved external symbol _IID_IDHTMLControlUI




Note: It appears that I am linking MyControls.lib incorrectly, however, I added MyControls.lib to Linker->Input->Additonal Dependencies & specified ../$(Configuration) in the Linker->General->Additional Library Directories.



Anyone have an idea?
Thanks!


Answer



The problem is related to how you link one project with the other. There is something missing here and since you don't show the code, it's a pure guess only.



On control project you have a type library which, when being built, also generates files MyControls_i.h, MyControls_i.c, MyControls_p.c. I suppose that on the application project you included _i.h file which declared symbols as externals, and you did not include the _i.c file with symbols actually defined.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...