gpt4 book ai didi

c++ - 1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32

转载 作者:太空宇宙 更新时间:2023-11-04 01:42:39 25 4
gpt4 key购买 nike

在运行 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

下面是我的代码

// 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;
}

最佳答案

您需要将您的应用程序与 d3d10.lib 链接起来。在 Visual Studio 中,您可以在链接器/输入/附加依赖项的项目设置中配置它。

关于c++ - 1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2705829/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com