1> main.obj:错误LNK2001:解析外部符号_D3D10CreateDeviceAndSwapChain @ 32 [英] 1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32
本文介绍了1> main.obj:错误LNK2001:解析外部符号_D3D10CreateDeviceAndSwapChain @ 32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
遇到了麻烦,我的DirectX会出现以下错误
1 GT;链接...
1> main.obj:错误LNK2001:解析外部符号_D3D10CreateDeviceAndSwapChain @ 32
1> C:\\用户\\ numerical25 \\桌面\\介绍ToDirectX \\ msdnTutorials \\ tutorial0 \\教程\\调试\\ tutorial.exe:致命错误LNK1120:1无法解析的外部
下面是我的code
//包含基本的Windows头文件
#包括LT&;&WINDOWS.H GT;
#包括LT&;&windowsx.h GT;
#包括LT&;&d3d10.h GT;ID3D10Device * g_pd3dDevice;
IDXGISwapChain * g_pSwapChain;
//将WindowProc函数原型
LRESULT CALLBACK的WindowProc(HWND的HWND,
UINT的消息,
WPARAM wParam中,
LPARAM lParam的);
布尔InitDirect3D(HWND);//切入点任何Windows程序
INT WINAPI的WinMain(HINSTANCE的hInstance,
HINSTANCE ^ h prevInstance,
LPSTR lpCmdLine,
INT的nCmdShow)
{
//手柄为窗口,通过函数填充
HWND的HWND;
//这个结构保存了窗口类信息
WNDCLASSEX厕所; //清除使用窗口类
ZeroMemory(安培; WC,的sizeof(WNDCLASSEX)); //在结构中填入需要的信息
wc.cbSize = sizeof的(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc =的WindowProc;
wc.hInstance =实例句柄;
wc.hCursor =使用LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground =(HBRUSH)COLOR_WINDOW;
wc.lpszClassName = LWindowClass1 //注册窗口类
RegisterClassEx(安培; WC); //创建窗口,并使用其结果作为所述手柄
的hWnd =函数CreateWindowEx(NULL,
LWindowClass1,窗口类名//
L我们的第一个窗计划,//窗口标题
WS_OVERLAPPEDWINDOW,//窗口风格
300,//窗口的x位置
300,//窗口的y位置
640,窗口//宽度
480,//窗口的高度
NULL,//我们没有父窗口,NULL
NULL,//我们不使用菜单,NULL
实例句柄,//应用程序句柄
空值); //使用多个窗口时,NULL //在屏幕上显示的窗口
的ShowWindow(HWND,的nCmdShow); //进入主循环: //这个结构持有的Windows事件消息
味精味精;
布尔完成= InitDirect3D(HWND); //进入无限的消息循环
而(TRUE)
{
//检查,看是否有消息在队列中等待
而(的PeekMessage(安培;味精,NULL,0,0,PM_REMOVE))
{
//翻译邮件,并将其派遣的WindowProc()
的TranslateMessage(安培;味精);
在DispatchMessage(安培;味精);
} //如果消息是WM_QUIT,退出while循环
如果(msg.message == WM_QUIT)
打破; //运行游戏code在这里
// ...
// ...
};
}//这是程序的主消息处理程序
LRESULT CALLBACK的WindowProc(HWND的HWND,UINT的消息,WPARAM wParam参数,LPARAM lParam的)
{
//分类和查找code为给定的消息运行
开关(消息)
{
//在关闭窗口读此消息
案例WM_DESTROY:
{
//完全关闭应用程序
PostQuitMessage(0);
返回0;
}打破;
} //处理switch语句没有任何消息
返回DefWindowProc函数(HWND,消息的wParam,lParam的);
}
布尔InitDirect3D(HWND g_hWnd)
{
DXGI_SWAP_CHAIN_DESC SD;
ZeroMemory(统计处,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;
如果(失败(D3D10CreateDeviceAndSwapChain(NULL,D3D10_DRIVER_TYPE_REFERENCE,NULL,
0,D3D10_SDK_VERSION,统计处,和放大器; g_pSwapChain,&安培; g_pd3dDevice)))
{
返回FALSE;
} 返回TRUE;
}
解决方案
您需要将应用程序与 d3d10.lib
链接。在Visual Studio中,你可以在链接器/输入/附加依赖项目设置进行配置。
having trouble getting my directx going I get the following error
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
. In Visual Studio you can configure this in the project settings in Linker / Input / Additional Dependencies.
这篇关于1&GT; main.obj:错误LNK2001:解析外部符号_D3D10CreateDeviceAndSwapChain @ 32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文