Question

I create Console Application in VC++ 2010, and add the following code to it:

#include <d3d10.h>
#include <d3dx10.h>
#include <DxErr.h>

#pragma comment(lib, "d3d10.lib")
#pragma comment(lib, "d3dx10.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "dxerr.lib")

int _tmain(int argc, _TCHAR* argv[])
{
    IDXGIFactory* pDXGIFactory;
    CreateDXGIFactory(IID_IDXGIFactory, ( void** )&pDXGIFactory);

    return 0;
}

Building this project, I have linker error: error LNK2001: unresolved external symbol _IID_IDXGIFactory

Now I create Console Application with MFC support, and add the same code. The build is successful. What is wrong in the first case? Why MFC project is built successfully, and non-MFC project fails?

Was it helpful?

Solution

You need to reference another library, which holds this identifier:

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

MSDN says its DXGI.lib but effectively at least Windows SDK 7.0 has it in a different library.

OTHER TIPS

I had the same issue and In my case referencing #pragma comment(lib, "dxgi.lib") solved the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top