Advertisement

Strange Error message

Started by July 30, 2002 05:50 AM
2 comments, last by pink_fruitloop 22 years, 3 months ago
I was trying to compile a .cpp file with the free borland compiler and I got this error message. Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland WinTut.cpp: Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland Error: Unresolved external ''_main'' referenced from C:\BORLAND\BCC55\LIB\C0X32.OBJ what does it mean and how can i fix it?
You have created a Console application which requires a main function.. ie.

void main()
{
}

whereas a windows application uses

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nShowCmd)
{

}

Advertisement
But it wont compile so what do i do heres the whole code:

#ifndef _WINDOWS_ // if windows.h is not included...
#include <windows> // include it!
#endif
#include "WinTut.h" //include WinTut header file


WinTut::WinTut(HINSTANCE hIns)
{
hInst = hIns;

winTutWndCls.cbSize = sizeof(WNDCLASSEX);
winTutWndCls.style = NULL;
winTutWndCls.lpfnWndProc = WndProc;
winTutWndCls.cbClsExtra = 0;
winTutWndCls.cbWndExtra = 0;
winTutWndCls.hInstance = hInst;
winTutWndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winTutWndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
winTutWndCls.hbrBackground = (HBRUSH)(COLOR_WINDOW);
winTutWndCls.lpszMenuName = NULL;
winTutWndCls.lpszClassName = "WinTutClass";
winTutWndCls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&winTutWndCls))
{
MessageBox(NULL, "Grrr!\nCould not register window class!", "ERROR", MB_OK | MB_ICONERROR);
}

hWnd = CreateWindowEx(WS_EX_APPWINDOW, "WinTutClass", "WinTut!", WS_OVERLAPPEDWINDOW, 0, 0, 300, 400, NULL, NULL, hInst, NULL);

if(hWnd == NULL)
{
MessageBox(NULL, "Could not create Window! ", "ERROR", MB_OK | MB_ICONERROR);
}
}

void WinTut::show(void)
{
ShowWindow(hWnd, SW_SHOW);
}



int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int)
{

MSG Msg;

WinTut mainWindow(hInst);
mainWindow.show();

while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{

case WM_CLOSE:

DestroyWindow(hWnd);

break;

case WM_DESTROY:

PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
I think what you need is

bcc32 -W file.cpp

Add the -W will cause the linker to link windows start up code.

Hope this helps.
Q:"Why it doesn''t work?"A:"There is a mistake."Q:"Who made that silly mistake?"A:"The one who write it."

This topic is closed to new replies.

Advertisement