error LNK2001:

来源:百度知道 编辑:UC知道 时间:2024/05/29 15:39:57
drawing.obj : error LNK2001: unresolved external symbol "int __cdecl Initwindows(struct HINSTANCE__ *,int)" (?Initwindows@@YAHPAUHINSTANCE__@@H@Z)

#include<windows.h>
#include<stdlib.h>
#include<string.h>
LRESULT CALLBACK WinProc(
HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam
);//声明消息处理函数
BOOL InitWindowsClass(HINSTANCE hInstance);

BOOL Initwindows(HINSTANCE hInstance,int nCmdShow);

int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
MSG message;
if (!InitWindowsClass(hInstance))
return FALSE;
if (!Initwindows(hInstance,nCmdShow))
return FALSE;
while(GetMessage(&message,0,0,0))//消息循环
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam;

}
LRESULT CALLBACK WinProc(
HWND hWnd,

你前面写的函数声明是:
BOOL Initwindows(HINSTANCE hInstance,int nCmdShow);
而后面的实现却是:
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);

注意,大小写有所不同,所以编译器会认为是两个函数!

这种错误表示VC++在链接时无法找到你想要的函数,象这种错误一般都是由于需要某些.LIB文件。你可以选择“Project|Settings”,在Link标签的Object/library modules部分加上所需的.LIB文件。如果你不知道哪个文件是你要的,可以使用搜索工具在VC的Lib目录中查找指定的符号,
在MSDN Library的帮助中,对于每个API函数都说明了其需要的头文件、库文件和适用的操作系统

编译器说找不到 Initwindows的实现,我觉得是你的{}不对,你在对应一下