Search code examples
visual-c++dxgi

CreateDXGIFactory function throws Linker Error


I am trying to experiment on the DXGI APIs, and I was creating a console application that enumerates the available Adapters from the Factory Object.

The Code Snippet is as shown below:

// pFactory and vecAdapters are initialized as static variables

// Snippet from a static function 
HRESULT result = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&pFactory);
if (result == S_OK) {
    UINT i = 0;
    IDXGIAdapter* pAdapter;
    while (pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND) {
        vecAdapters.push_back(pAdapter);
        ++i;
    }
}

But I am getting a Linker Error as follows:

error LNK2019: unresolved external symbol _CreateDXGIFactory@8

The headers that I have used are the following:

#include <Windows.h>
#include <dxgi.h>
#include <dxgi1_2.h>
#include <vector>

Am I missing something?

And thank you so much in advance for helping me out!


Solution

  • #pragma comment(lib, "dxgi.lib")