Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CreateDXGIFactory function throws Linker Error [duplicate]

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!

like image 595
Ashik Unni Avatar asked Mar 25 '26 03:03

Ashik Unni


1 Answers

  • Linker Error for CreateDXGIFactory Function
  • also related Unresolved external symbol _IID_IDXGIFactory

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

like image 100
Roman R. Avatar answered Mar 27 '26 18:03

Roman R.