【问题标题】:Visual Studio not creating a .exeVisual Studio 未创建 .exe
【发布时间】:2013-02-12 22:57:55
【问题描述】:

实际上我刚刚发现另一个与我自己相同的线程已解决,抱歉重复。

已解决线程的链接:DirectX unresolved external error

所以我开始在入门书的帮助下尝试一些 DirectX 11,尽管在我第一次调试时我遇到了错误:S

我什至从书中逐字复制代码,以确保我没有犯任何愚蠢的语法错误,尽管我仍然收到错误:

无法启动程序“C:.....\DXBlankWindow.exe”。系统找不到指定的文件。

错误一:

错误 LNK2019:函数 _wWinMain 中引用了无法解析的外部符号“long stdcall WndProc(struct HWND *,unsigned int,unsigned int,long)”(?WndProc@@YGJPAUHWND__@@IIJ@Z) @16 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

检查项目调试文件夹后,没有创建 .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.

【问题讨论】:

标签: c++ visual-studio file directx executable


【解决方案1】:
// Define WndProc
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );

不,这没有定义WndProc声明 WndProc。换句话说,这告诉您的其余代码在某处有一个WndProc,因此wndClass.lpfnWndProc = WndProc; 不会导致编译错误。确保您确实拥有WndProc,这取决于您。这就是链接器错误消息试图告诉您的内容。

或者,更简单地说,如果你告诉系统使用一个不存在的WndProc,那么系统除了告诉你之外什么也做不了。

编辑:查看副本,您似乎使用的是一本样本不完整的书。我对这本书不熟悉,但如果这给你带来了麻烦,你可能想再找一本书。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    相关资源
    最近更新 更多