2013-02-12 46 views
0

我实际上刚刚发现了另一个线程与我自己的已经解决的相同,对于重复对不起。Visual Studio没有创建一个.exe

链接到解决线程:DirectX unresolved external error

于是我开始尝试一些的DirectX 11与初学者的书的帮助,虽然我的第一个调试我有错误:S

我VE甚至复制的码字从书上的文字只是为了确保我没有做任何愚蠢的错误回报的语法,但我仍然得到错误:

Unable to start program 'C:.....\DXBlankWindow.exe'. The system cannot find the file specified.

错误1:

error LNK2019: unresolved external symbol "long stdcall WndProc(struct HWND *,unsigned int,unsigned int,long)" ([email protected]@[email protected]@[email protected]) referenced in function [email protected] C:\Users\Tim\Documents\Visual Studio 2010\Projects\DirectXTuts\DXBlankWindow\DXBlankWindow\main.obj

错误2:

error LNK1120: 1 unresolved externals C:\Users\Tim\Documents\Visual Studio 2010\Projects\DirectXTuts\DXBlankWindow\Debug\DXBlankWindow.exe 1

和检查项目的debug文件夹中没有创建一个.exe文件之后。我也运行了一个简单的程序来检查项目是否会运行,它做得很好,并创建了.exe文件,并且我已经将运行时库更改为“多线程调试(/ MTd)”。

我可能在做一些非常基本的和非常简单的错误,但我不能为我的生活制定出什么。任何帮助真的很感激。我想那里有什么可说的以外,这里的代码:

#include<Windows.h> 

// Define WndProc 
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 

// Program Entry Point 
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow) 
{ 

// Define unused parameters 
UNREFERENCED_PARAMETER(prevInstance); 
UNREFERENCED_PARAMETER(cmdLine); 

// Define Window variables 
WNDCLASSEX wndClass = { 0 }; 
wndClass.cbSize = sizeof(WNDCLASSEX) ; 
wndClass.style = CS_HREDRAW | CS_VREDRAW; 
wndClass.lpfnWndProc = WndProc; 
wndClass.hInstance = hInstance; 
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); 
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 
wndClass.lpszMenuName = NULL; 
wndClass.lpszClassName = "DX11BookWindowClass"; 

// Check if wndClass is being registered, if not error. 
if(!RegisterClassEx(&wndClass)) 
return -1; 

// Create a RECT to hold the screen positions 
RECT rc = { 0, 0, 640, 480 }; 
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); 


// Create The Window through ANSI 
HWND hwnd = CreateWindowA("DX11BookWindowClass", "Blank Win32 Window", 
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc. left, 
rc.bottom - rc.top, NULL, NULL, hInstance, NULL); 

if(!hwnd) 
return -1; 

ShowWindow(hwnd, cmdShow); 


// Demo Initialize 

MSG msg = { 0 }; 

while(msg.message != WM_QUIT) 
{ 
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) 
{ 
TranslateMessage(&msg); 
DispatchMessage(&msg); 
} 

// Update 
// Draw 
} 

// Demo Shutdown 

return static_cast<int>(msg.wParam); 
} 

Thanks again. 
+0

可能重复的[DirectX无法解析的外部错误](http://stackoverflow.com/questions/11659157/directx-unresolved-external-error) – hvd 2013-02-12 23:07:58

+0

这应该可能被称为链接器错误ERROR2019,因为我猜这就是问题 – 2013-02-12 23:09:05

回答

2
// Define WndProc 
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 

不,没有定义WndProc,那声明WndProc。换句话说,它告诉你的代码的其余部分有一个WndProc的地方,所以wndClass.lpfnWndProc = WndProc;不会导致编译错误。这取决于你确保你确实拥有WndProc。这是链接器错误消息试图告诉你的。

或者说简单一点,如果你告诉系统使用不存在的WndProc,那么系统不能做任何事情,只能告诉你。

编辑:看着重复,你似乎正在使用一本书不完整的样本。我对这本书并不熟悉,但是如果这给你带来了麻烦,你可能需要寻找另一本书。

相关问题