2013-04-17 2 views
3

DirectX 11을 사용하여 잠시 작업하려했는데, 먼저 Visual Studio 2010에 Windows 7이 있고 Direct3D 장치를 만들지 않을 때 SDK 버그가 발생했습니다. . 그래서 SDK를 제거하고 Visual Studio 2012를 설치하고 완전히 새로운 코드 세트를 사용하여 창을 만들었습니다.직접 x 11 창을 만들려고하는 중 링커 오류가 발생했습니다.

error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl InitD3D(struct HWND__ *)" ([email protected]@[email protected]@@Z) C:\Users\thatguy\Documents\game dev\tutorial work\directx 11 tutorial\directx 11 tutorial\main.obj directx 11 tutorial 

이 내가 컴파일하려고 코드입니다 :

내 프로젝트 구축을 위해 노력하면 지금 얻을 오류입니다

나는 다이렉트를 추가 한
// include the basic windows header files and the Direct3D header files 
#include <windows.h> 
#include <windowsx.h> 
#include <d3d11.h> 
#include <d3dx11.h> 
#include <d3dx10.h> 

// include the Direct3D Library file 
#pragma comment (lib, "d3d11.lib") 
#pragma comment (lib, "d3dx11.lib") 
#pragma comment (lib, "d3dx10.lib") 

// global declarations 
IDXGISwapChain *swapchain;    // the pointer to the swap chain interface 
ID3D11Device *dev;      // the pointer to our Direct3D device interface 
ID3D11DeviceContext *devcon;   // the pointer to our Direct3D device context 

// function prototypes 
void InitD3D(HWND hWnd); // sets up and initializes Direct3D 
void CleanD3D(void);  // closes Direct3D and releases memory 

// the WindowProc function prototype 
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 


// the entry point for any Windows program 
int WINAPI WinMain(HINSTANCE hInstance, 
        HINSTANCE hPrevInstance, 
        LPSTR lpCmdLine, 
        int nCmdShow) 
{ 
    HWND hWnd; 
    WNDCLASSEX wc; 

    ZeroMemory(&wc, sizeof(WNDCLASSEX)); 

    wc.cbSize = sizeof(WNDCLASSEX); 
    wc.style = CS_HREDRAW | CS_VREDRAW; 
    wc.lpfnWndProc = WindowProc; 
    wc.hInstance = hInstance; 
    wc.hCursor = LoadCursor(NULL, IDC_ARROW); 
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW; 
    wc.lpszClassName = "WindowClass"; 

    RegisterClassEx(&wc); 

    RECT wr = {0, 0, 800, 600}; 
    AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); 

    hWnd = CreateWindowEx(NULL, 
          "WindowClass", 
          "Our First Direct3D Program", 
          WS_OVERLAPPEDWINDOW, 
          300, 
          300, 
          wr.right - wr.left, 
          wr.bottom - wr.top, 
          NULL, 
          NULL, 
          hInstance, 
          NULL); 

    ShowWindow(hWnd, nCmdShow); 

    // set up and initialize Direct3D 
    InitD3D(hWnd); 

    // enter the main loop: 

    MSG msg; 

    while(TRUE) 
    { 
     if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 
     { 
      TranslateMessage(&msg); 
      DispatchMessage(&msg); 

      if(msg.message == WM_QUIT) 
       break; 
     } 
     else 
     { 
      // Run game code here 
      // ... 
      // ... 
     } 
    } 

    // clean up DirectX and COM 
    CleanD3D(); 

    return msg.wParam; 
} 


// this is the main message handler for the program 
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 
{ 
    switch(message) 
    { 
     case WM_DESTROY: 
      { 
       PostQuitMessage(0); 
       return 0; 
      } break; 
    } 

    return DefWindowProc (hWnd, message, wParam, lParam); 
} 


// this function initializes and prepares Direct3D for use 
void InitD3D(HWND hWnd) 
{ 
    // create a struct to hold information about the swap chain 
    DXGI_SWAP_CHAIN_DESC scd; 

    // clear out the struct for use 
    ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC)); 

    // fill the swap chain description struct 
    scd.BufferCount = 1;         // one back buffer 
    scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;  // use 32-bit color 
    scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;  // how swap chain is to be used 
    scd.OutputWindow = hWnd;        // the window to be used 
    scd.SampleDesc.Count = 4;        // how many multisamples 
    scd.Windowed = TRUE;         // windowed/full-screen mode 

    // create a device, device context and swap chain using the information in the scd struct 
    D3D11CreateDeviceAndSwapChain(NULL, 
            D3D_DRIVER_TYPE_HARDWARE, 
            NULL, 
            NULL, 
            NULL, 
            NULL, 
            D3D11_SDK_VERSION, 
            &scd, 
            &swapchain, 
            &dev, 
            NULL, 
            &devcon); 
} 


// this is the function that cleans up Direct3D and COM 
void CleanD3D(void) 
{ 
    // close and release all existing COM objects 
    swapchain->Release(); 
    dev->Release(); 
    devcon->Release(); 
} 

디렉토리를 포함하고 lib x64 및 x86 디렉토리에 있지만 여전히 실패합니다.

+0

링커 옵션에서/VERBOSE를 활성화하고 올바른 라이브러리가 가져 오기되었는지 다시 확인하십시오. 디렉토리 설정이 잘못되었을 수 있습니다. –

답변

5

속성 -> 링커 -> 입력 -> 추가 종속성에 D3D11.lib를 추가해야합니다.

시도해 보셨습니까?

+1

나는 그것과 똑같은 정확한 오류를 만들지 않으려 고 노력했다. –

+0

그는'#pragma comment (lib, "d3d11.lib")'를 이미 가지고 있습니다. –

+0

앱을 32 비트 또는 64 비트로 컴파일하고 있습니까? – neur0tic