Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Compile Error - Simple Win32 Program

Compile Error - Simple Win32 Program

Compile Error - Simple Win32 Program

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>

    switch (iMsg) {
        case WM_LBUTTONDOWN:
            MessageBox(hWnd, "Left mouse button pressed", "6E69636F6C65282A29", MB_OK);
            return 0;
        case WM_RBUTTONDOWN:
            MessageBox(hWnd, "Right mouse button pressed", "6E69636F6C65282A29", MB_OK);
            return 0;
        case WM_DESTROY:
            return 0;
    return DefWindowProc(hWnd, iMsg, wParam, lParam);

int WINAPI WinMain(HINSTANCE hInstance, int iCmdShow) {
    const char *const szAppName = "Windows";
    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);


    hWnd = CreateWindow(szAppName, "Windows", WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);
    ShowWindow(hWnd, iCmdShow);

    while (GetMessage(&msg, NULL,0,0)) {
    return msg.wParam;

RE: Compile Error - Simple Win32 Program

In plain language, compile it with:
  bcc32 -tW myprog
instead of:
  bcc32 myprog
This makes the compiler create a Windows vs a DOS-style exe file.

RE: Compile Error - Simple Win32 Program

as zBuilder mentioned, you're not compiling it properly, create a new project of type Win32 GUI, then compile it, the way you have it set up, it's looking for main(){} not WinMain(){}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close