在链接期间在WINAPI中收到奇怪的错误

时间:2014-01-21 15:46:06

标签: c winapi linker

这是我在链接过程中遇到的错误:

main.obj : error LNK2001: unresolved external symbol "long __stdcall windowProcess(struct HWND__ *,unsigned int,unsigned int,long)" (?windowProcess@@YGJPAUHWND__@@IIJ@Z)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

main.exe - 3 error(s), 0 warning(s)

这是我的源代码

#include <windows.h>
//#include <stdlib.h>
//#include <string.h>
#include "stdafx.h"

//1. Declaring windowProcess of type LRESULT
//2. WIN API
//3. WIndow Class
//4. Register Class
//5. Create Window
//6. Show Window

// The main window class name
const char myClassName[] = "myClass";



//1. Moving towards 1st step & showing the ass of Window Process
LRESULT CALLBACK windowProcess(HWND,UINT,WPARAM,LPARAM);

//2. Using win api
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevIntance,
                   LPSTR lpcmdLine,
                   int comandNumber){

WNDCLASS wc;
wc.style=CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc=windowProcess;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_APPLICATION));
wc.hbrBackground=NULL;
wc.lpszMenuName=NULL;
wc.lpszClassName=myClassName;

//3. Registering Wnd Class
if(!RegisterClass(&wc))
    {
        MessageBox(NULL,"Class didnot get registered","An Simple Window Application",NULL);
    }
//hint=hInstance;

//4. registering window class
HWND hWnd=CreateWindow(myClassName,"Title f Window",WS_OVERLAPPEDWINDOW,0,0,500,100,NULL,NULL,hInstance,NULL);

if(!hWnd)
    {
        MessageBox(NULL,"window didnt created","An Simple Windw Application",NULL);
    }
//5. Now after window has been created lets show this window
ShowWindow(hWnd,comandNumber);
UpdateWindow(hWnd);
return 1;
}//winapi WinMain function ends

2 个答案:

答案 0 :(得分:0)

错误告诉您该功能

LRESULT CALLBACK windowProcess(HWND,UINT,WPARAM,LPARAM);

只能在任何地方声明和定义。

答案 1 :(得分:0)

检查项目道具 - &gt;链接器 - &gt;系统 - &gt;子系统。