Solved

linker error for awindows 98 program in c++

Posted on 2002-05-10
9
211 Views
Last Modified: 2010-04-02
i have just started learning windows 98 programming and am stuck with the first program that is simple window skeleton creation i use windows 98 second edition and have compiled the code in turboc++,vc++ bc++and am getting the linker error unresolved external symbol _main in  crto.obj plaese help so that i could go on further.
     satish
0
Comment
Question by:satishkr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 4

Accepted Solution

by:
mblat earned 50 total points
ID: 7002209
Are you building ATL project?  

If so resolution here is to remove _ATL_MIN_CRT from the list the preprocessor defines to allow CRT startup code to be included.

From the Project menu, click Settings.

In the Settings For drop-down list, select Multiple Configurations.

In the Select project configuration(s) to modify dialog box that displays, select the check boxes for all release versions, and then click OK.

Click the C/C++ tab in the Project Settings dialog box, and then choose the General category.

Remove _ATL_MIN_CRT from the Preprocessor definitions edit box.

Hope it helps....

( instructions for VC++ )
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 7002354
Do you have a function called main() in your code?    
Can you post the function prototype for  your main() here?

Is this a console (DOS) app or something else?      
0
 

Author Comment

by:satishkr
ID: 7003322
yes i do have a function called WinMAin in my code
and here is the actual code try compiling ur self and let me know
/*a minimal windows 98 skeleton */
#include <windows.h>

LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
char szWinName[] = "MyWin"; /*name of window class*/
int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpSzArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;

/* define a window class */
wcl.cbSize = sizeof(WNDCLASSEX);

wcl.hInstance = hThisInst; /* handle to this instance */
wcl.lpszClassName = szWinName; /* window class anme */
wcl.lpfnWndProc = WindowFunc; // window function
wcl.style = 0; //defaultstyle

wcl.hIcon = LoadIcon(NULL,IDI_APPLICATION); //standard icon
wcl.hIconSm = LoadIcon(NULL,IDI_WINLOGO); //small icon
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);//cursor style

wcl.lpszMenuName = NULL; // no menu
wcl.cbClsExtra = 0; //no extra information needed
wcl.cbWndExtra = 0; //no extra informaton needed

//make the window background white
wcl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);

//register the window class
if(!RegisterClassEx(&wcl)) return 0;

//now that a window class has been registered , a window can be created
hwnd = CreateWindowA(
  szWinName, /*name of window class*/
  "Windows 98 Skeleton", //title
  WS_OVERLAPPEDWINDOW,//window style - normal
  CW_USEDEFAULT,//x coordinate let windows decide
  CW_USEDEFAULT,//y coordinate let windows decide
  CW_USEDEFAULT,//width let windows decide
  CW_USEDEFAULT,//height let windows decide
  HWND_DESKTOP,//no parent window
  NULL, //no menu
  hThisInst, //handle of this instance of the program
  NULL //no additional arguments
  );


  //display the window
  ShowWindow(hwnd, nWinMode);
  UpdateWindow(hwnd);

  //create the message loop
  while(GetMessage(&msg, NULL, 0, 0))
  {
  TranslateMessage(&msg); //translate keyboard messages
  DispatchMessage(&msg); //return control to windows 98
  }
  return msg.wParam;
  }

  //this function is called by windows 98 and is passed messages from
   //the message queue
  LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,
   LPARAM lParam)
  {
  switch(message) {
    case WM_DESTROY: //terminate the program
      PostQuitMessage(0);
      break;
      default:
      //let windows 98 process any message not specified in the
      //preceding switch statement.
      return DefWindowProc(hwnd,message,wParam,lParam);
      }


     
      return 0;
      }


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:satishkr
ID: 7003333
sorry guys for not putting my question properly i dont get any errors when compiling in any compiler but i get the same linker error in all the compilers (tc,bc++,
Vc++ ver6.0) the author of thebook windows 98 programming has specified that all the code can be run with vc++and has asked not to select any class library support
0
 
LVL 4

Expert Comment

by:mblat
ID: 7003634
ok, my guess here is that you creating wrong type of project.

See, when you just type text to a file and ask compiler to compile it, VC++ creates default project, which is Win32 CONSOLE app.

What you need is Win32 Application type of project.

So go to VC++. Say File->New->Projects->Win32 Application.  Select "Empty project".

Then you need to add your file to a project.
To do so:
 expand project tree, right click on "source file", select "Add file to project".


Hope it helps...
0
 

Author Comment

by:satishkr
ID: 7004369
mblat yur suggestion has worked thank u i got the output thanks a lot
0
 
LVL 4

Expert Comment

by:mblat
ID: 7004655
So where is the grade then? :-)
0
 
LVL 11

Expert Comment

by:griessh
ID: 7178721
Dear satishkr

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "mblat"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7199774
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question