error LNK2001: unresolved external symbol _IID_IDirectDraw2

孤街醉人 提交于 2020-01-04 11:04:15

问题


I work with piece of legacy code which uses direct draw and I'm in rather embarrassing situation. Not long ago I've updated my system and had to adapt to the new situation (loading ddraw.dll) and everything worked fine. Today I explored another legacy solution which also uses classes (files) I've changed, but I'm stuck with above mentioned linking error. I've checked and compared project properties and they seam fine.

This is code for directX initialization, "troublesome" code is bold.

 typedef int (__stdcall *DirectDrawCreateFunc)(GUID FAR* a ,LPDIRECTDRAW FAR* b, IUnknown FAR* c);

    /* init_directx:
     *  Low-level DirectDraw initialization routine.
     */
    int CDCUtils::init_directx(HWND allegro_wnd)
    {
       LPDIRECTDRAW directdraw1;
       HRESULT hr;
       LPVOID temp;
       HINSTANCE ddraw = LoadLibrary("%WINDIR%\system32\ddraw.dll");
       if(ddraw== NULL)
       {
           return -1;
       }
       _ddrawLib =ddraw;
    DirectDrawCreateFunc ddFunc = (DirectDrawCreateFunc)GetProcAddress(ddraw,"DirectDrawCreate");
    if(ddFunc)
    {
     /* first we have to set up the DirectDraw1 interface... */
       hr = ddFunc(NULL, &directdraw1, NULL);
       if (FAILED(hr))
          return -1;
    }

       ///* first we have to set up the DirectDraw1 interface... */
       //hr = DirectDrawCreate(NULL, &directdraw1, NULL);
       //if (FAILED(hr))
       //   return -1;

       //...then query the DirectDraw2 interface
       //This is the only place where IID_IDirectDraw2 is mentioned in entire solution
       hr=directdraw1->QueryInterface(IID_IDirectDraw2, &temp);
       if (FAILED(hr))
          return -1;

       _directdraw = (LPDIRECTDRAW2)temp;
       directdraw1->Release();

       /* set the default cooperation level */
       hr = IDirectDraw2_SetCooperativeLevel(_directdraw, allegro_wnd, DDSCL_NORMAL);
       if (FAILED(hr))
          return -1;

       /* get capabilities */
       _ddcaps.dwSize = sizeof(_ddcaps);
       hr = IDirectDraw2_GetCaps(_directdraw, &_ddcaps, NULL);
       if (FAILED(hr)) {
          TRACE("Can't get driver caps\n");
          return -1;
       }

       _dxHwnd=allegro_wnd;
      return 0;
    } 

Any ideas? Why it works in one solution and not in this one? Oh linker I loathe thee.


回答1:


Did you add dxguid.lib to your project's linker inputs?




回答2:


Make sure you add Dxguid.lib in your project.



来源:https://stackoverflow.com/questions/5966042/error-lnk2001-unresolved-external-symbol-iid-idirectdraw2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!