Solved

linker error for awindows 98 program in c++

Posted on 2002-05-10
9
201 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maze travler 6 47
Want to delete all my personal data 13 127
I could not build boost code, 10 52
c++ syntax question 9 34
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now