×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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

how to compile windows program in borland 5.5

how to compile windows program in borland 5.5

how to compile windows program in borland 5.5

(OP)
My Borland 5.5 c++ compiler won't compile even a simple windows program. When I try the same program in VC++ it compiles ok.

The error I get in Borland is:

Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\C0X32.OBJ

what does this mean?

RE: how to compile windows program in borland 5.5

If your program goes something like this:

int main()
{
//code here
return 0;
}

Then you need to compile your program as a 32bit windows console application.... Otherwise if it starts something like this:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE PrevInstance, LPSTR lpCmdLine, INT nCmdShow)

You just compile it as a normal 32bit windows application.


 
Kim_Christensen@telus.net
http://www3.bc.sympatico.ca/Kim_Christensen/index.html
 

RE: how to compile windows program in borland 5.5

(OP)
Actually the program is already a win32 application with the the proper windows functions. All it does is display a window and compiles and runs fine in VC++. The problem seems to be something else. Here's the code:



#include <windows.h>

static char pClassName[] = "TheClass";
static HINSTANCE ghInst = 0;

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case CM_CLOSEWIN: DestroyWindow(hwnd); break;
        case WM_CLOSE: DestroyWindow(hwnd); break;
        case WM_DESTROY: PostQuitMessage(0); break;
        default: return DefWindowProc(hwnd, Message, wParam, lParam);
    }
    return 0;
}


int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wce;
    HWND hwnd;
    MSG msg;
    ghInst = hInstance;

    wce.cbSize = sizeof(WNDCLASSEX);
    wce.style = 0;
    wce.lpfnWndProc = WndProc;
    wce.cbClsExtra = 0;
    wce.cbWndExtra = 0;
    wce.hInstance = ghInst;
    wce.hIcon = LoadIcon(0, IDI_WINLOGO);
    wce.hCursor = LoadCursor(0, IDC_ARROW);
    wce.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wce.lpszMenuName = 0;
    wce.lpszClassName = pClassName;
    wce.hIconSm = LoadIcon(0, IDI_WINLOGO);

    if(!RegisterClassEx(&wce))return 0;

    hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, pClassName, "title", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
        800, 600, 0, 0, ghInst, 0);

    if(hwnd == 0) return 0;

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    while(GetMessage(&msg, 0, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}

RE: how to compile windows program in borland 5.5

  Hi,
  I use batch files. Below is a sample.

  FIRST FILE TO COMPILE SOURCE C OR CPP

  bcc32 -c -w- -tW wingen.cpp


  SECOND TO COMPILE RC FILE

  brcc32 -w32 myrsrce.rc

  THIRD TO LINK OBJ AND RES  *NOTE  "iLink32" IS NOT A LINK BUT THE LINKER PROG

  iLink32 -Tpe -aa c0w32.obj wingen.obj , wingen.exe, ,import32.lib cw32mt.lib, ,myrsrce.res

  del *.ils
  del *.ilf
  del *.ilc
  del *.ild
  del *.tds
  del *.map

  DEL LINES TO GET RID OF INTERMEDIATE FILES

  I put the deviders in CAPS to seperate the three files.
  wingen.cpp is what I wrote to use as a template(NOT CPP template)for starting a windows program.

  Hope this helps.

Pappy
You learn somrthing everyday.

RE: how to compile windows program in borland 5.5

(OP)
Thank you Pappy1942. From your batch script I see the problem now. It was the -tW option.

bcc32 test.cpp
doesn't work for windows apps....

bcc32 -tW test.cpp
does.

so for example:

#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int cmdShow)
{MessageBox(0, "ok", "ok", MB_OK); return 0;}

compiles and runs ok displaying a simple pop-up.
Thanks a bunch.

Thanks also zBuilder for responding.

RE: how to compile windows program in borland 5.5

Also you might want to look at make files.

James P. Cottingham
www.ivcusa.com

RE: how to compile windows program in borland 5.5

(OP)
Yeah. I'm going to do that next. The whole reason for opting to use borland is because VC++ seems to do do a lot of stuff "for you". I feel like I'll understand what's going on better if I use a more manual compiler like borland.

RE: how to compile windows program in borland 5.5

(OP)
I found this thread which answers some issues I was asking about.  Thanks for the great info Pappy1942.  How would one put this ugly mess of -flags and ,,options into a make file?  I certainly don't look forward to typing in that iLink32 thing every time!  The info on make is very, very sketchy in the documentation.

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