简体   繁体   English

1> main.obj:错误LNK2001:未解析的外部符号_D3D10CreateDeviceAndSwapChain @ 32

[英]1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32

having trouble getting my directx going I get the following error 无法让我的directx运行,我得到以下错误

1>Linking...
1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32
1>C:\Users\numerical25\Desktop\Intro ToDirectX\msdnTutorials\tutorial0\tutorial\Debug\tutorial.exe : fatal error LNK1120: 1 unresolved externals

below is my code 下面是我的代码

// include the basic windows header file
#include <windows.h>
#include <windowsx.h>
#include <d3d10.h>

ID3D10Device* g_pd3dDevice;
IDXGISwapChain* g_pSwapChain;


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

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    // the handle for the window, filled by a function
    HWND hWnd;
    // this struct holds information for the window class
    WNDCLASSEX wc;

    // clear out the window class for use
    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    // fill in the struct with the needed information
    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 = L"WindowClass1";

    // register the window class
    RegisterClassEx(&wc);

    // create the window and use the result as the handle
    hWnd = CreateWindowEx(NULL,
                          L"WindowClass1",    // name of the window class
                          L"Our First Windowed Program",   // title of the window
                          WS_OVERLAPPEDWINDOW,    // window style
                          300,    // x-position of the window
                          300,    // y-position of the window
                          640,    // width of the window
                          480,    // height of the window
                          NULL,    // we have no parent window, NULL
                          NULL,    // we aren't using menus, NULL
                          hInstance,    // application handle
                          NULL);    // used with multiple windows, NULL

    // display the window on the screen
    ShowWindow(hWnd, nCmdShow);

    // enter the main loop:

    // this struct holds Windows event messages
    MSG msg;
    bool finished = InitDirect3D(hWnd);

    // Enter the infinite message loop
    while(TRUE)
    {
        // Check to see if any messages are waiting in the queue
        while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // Translate the message and dispatch it to WindowProc()
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        // If the message is WM_QUIT, exit the while loop
        if(msg.message == WM_QUIT)
            break;

        // Run game code here
        // ...
        // ...
    };
}

// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    // sort through and find what code to run for the message given
    switch(message)
    {
        // this message is read when the window is closed
        case WM_DESTROY:
            {
                // close the application entirely
                PostQuitMessage(0);
                return 0;
            } break;
    }

    // Handle any messages the switch statement didn't
    return DefWindowProc (hWnd, message, wParam, lParam);
}


bool InitDirect3D(HWND g_hWnd)
{
    DXGI_SWAP_CHAIN_DESC sd;
    ZeroMemory( &sd, sizeof(sd) );
    sd.BufferCount = 1;
    sd.BufferDesc.Width = 640;
    sd.BufferDesc.Height = 480;
    sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    sd.BufferDesc.RefreshRate.Numerator = 60;
    sd.BufferDesc.RefreshRate.Denominator = 1;
    sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    sd.OutputWindow = g_hWnd;
    sd.SampleDesc.Count = 1;
    sd.SampleDesc.Quality = 0;
    sd.Windowed = TRUE;


    if( FAILED( D3D10CreateDeviceAndSwapChain( NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL,
                     0, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice ) ) )
    {
        return FALSE;
    }

    return TRUE;
}

You need to link your application with d3d10.lib . 您需要将您的应用程序与d3d10.lib链接。 In Visual Studio you can configure this in the project settings in Linker / Input / Additional Dependencies. 在Visual Studio中,您可以在链接器/输入/附加依赖项的项目设置中进行配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 函数“ public:bool”中引用的未解析的外部符号_D3D10CreateDeviceAndSwapChain @ 32 - unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "public: bool 错误LNK2001:无法解析的外部符号_D3DX10CreateTextureFromFileW @ 24 - error LNK2001: unresolved external symbol _D3DX10CreateTextureFromFileW@24 libcmtd.lib(exe_main.obj) 错误 lnk2001 无法解析的外部符号 main - libcmtd.lib(exe_main.obj) error lnk2001 unresolved external symbol main 错误LNK2001:无法解析的外部符号_Main - error LNK2001: unresolved external symbol _Main “错误LNK2001:无法解析的外部符号_main”仍然存在 - “Error LNK2001: unresolved external symbol _main” still exists 错误LNK2001:无法解析的外部符号 - error LNK2001: unresolved external symbol 错误LNK2001:无法解析的外部符号 - error LNK2001: unresolved external symbol 错误LNK2001:cocos2d-x lua支持中的未解析外部符号 - error LNK2001: unresolved external symbol in cocos2d-x lua support 使用Direct2d效果时如何解决“错误LNK2001:未解析的外部符号_CLSID_D2D1Blend”? - How to solve “error LNK2001: unresolved external symbol _CLSID_D2D1Blend” when using Direct2d Effects? 编译错误:core.obj:错误LNK2001:未解析的外部符号_harmony_core_init - Error in compiling: core.obj : error LNK2001: unresolved external symbol _harmony_core_init
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM