Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 错误LNK2001:未解析的外部符号_IID_IDirectDraw2_C++_Linker_Directdraw - Fatal编程技术网

C++ 错误LNK2001:未解析的外部符号_IID_IDirectDraw2

C++ 错误LNK2001:未解析的外部符号_IID_IDirectDraw2,c++,linker,directdraw,C++,Linker,Directdraw,我使用的是一段使用直接绘图的遗留代码,我现在的处境相当尴尬。 不久前,我更新了我的系统,不得不适应新的情况(加载ddraw.dll),一切都很好。 今天我探索了另一个遗留解决方案,它也使用了我更改过的类(文件),但我遇到了上面提到的链接错误。我已经检查并比较了项目属性,它们很好 这是directX初始化的代码,“麻烦”代码是粗体的 typedef int (__stdcall *DirectDrawCreateFunc)(GUID FAR* a ,LPDIRECTDRAW FAR* b, IU

我使用的是一段使用直接绘图的遗留代码,我现在的处境相当尴尬。 不久前,我更新了我的系统,不得不适应新的情况(加载ddraw.dll),一切都很好。 今天我探索了另一个遗留解决方案,它也使用了我更改过的类(文件),但我遇到了上面提到的链接错误。我已经检查并比较了项目属性,它们很好

这是directX初始化的代码,“麻烦”代码是粗体的

 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;
    } 
有什么想法吗? 为什么它在一个解决方案中有效而在这个解决方案中无效?
哦,我讨厌你

是否已将
dxguid.lib
添加到项目中?

请确保将dxguid.lib添加到项目中。

嗯。。。它不是自动链接到其他Lib目录->[My_DirectX\u SDK\u Location\Lib\x86]?@Deka:不是--告诉链接器某些.Lib文件存在的位置与告诉链接器实际链接给定的.Lib文件不同。我的另一个使用相同文件的项目在项目输入中没有链接,并且工作正常。它也不是通过#pragma comment链接的。@Deka:那么,你是否将它添加到链接器输入中了?如果没有,试试看。我已经链接了它,它也可以工作,但为什么我不必在其他项目中链接它@德卡:唯一合理的解释是,另一个项目确实以某种方式将其链接起来,或者它在内部某处定义了值本身。在任何情况下,链接
dxguid.lib
都是正确的解决方案。