2013-02-12 79 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,那麼系統不能做任何事情,只能告訴你。

編輯:看着重複,你似乎正在使用一本書不完整的樣本。我對這本書並不熟悉,但是如果這給你帶來了麻煩,你可能需要尋找另一本書。

相關問題