Solved

linker error for awindows 98 program in c++

Posted on 2002-05-10
9
209 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
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

829 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