Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Erroe

Status
Not open for further replies.

aibo

Technical User
Sep 30, 2007
9
I wrote this prorgam, but when I try and compile I get the error "Unresolved external '_main' referenced from D:\BORLAND\BCC55\LIB\COX32.OBJ". The compile does generate the .obj, and .tds files, but not the .exe. Here is the program:

#define STRICT
#include <windows.h>

LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
switch (iMsg) {
case WM_LBUTTONDOWN:
MessageBox(hWnd, &quot;Left mouse button pressed&quot;, &quot;6E69636F6C65282A29&quot;, MB_OK);
return 0;
case WM_RBUTTONDOWN:
MessageBox(hWnd, &quot;Right mouse button pressed&quot;, &quot;6E69636F6C65282A29&quot;, MB_OK);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, int iCmdShow) {
const char *const szAppName = &quot;AiBo&quot;;
WNDCLASSEX wndclass;
HWND hWnd;
MSG msg;

wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

RegisterClassEx(&wndclass);

hWnd = CreateWindow(szAppName, &quot;Click a mouse button&quot;, WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);

while (GetMessage(&msg, NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
 
You should create at the first a Win32 API project. After, you may add your program to your project. The error what you've shown means you have created a Console program (DOS program) what require function main().
By the way, everytime when you want to create a program, you should begin from creating a project even you create a console or a WinAPI program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top