Wooo

Crono5Crono5 Join Date: 2003-07-22 Member: 18357Members
<div class="IPBDescription">C++ Problems</div> Okay, my compiler won't compile a simple program I made to make a Windows message box appear.

<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance,
      HINSTANCE hPrevInstance,
      LPSTR lpCmdLine,
      int nShowCmd)
{
MessageBox(NULL,
     "GASP",
     "Message Box",
     MB_OK);
return 0;
}<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

That's the linker error I get. Someone wanna tell me what that means and how I get rid of it?

MSVC++ 6

Comments

  • DOOManiacDOOManiac Worst. Critic. Ever. Join Date: 2002-04-17 Member: 462Members, NS1 Playtester
    erm.. I know nothing abuot winapi but.. don't you need a main() SOMEWHERE?
  • Crono5Crono5 Join Date: 2003-07-22 Member: 18357Members
    main is for the console, you use WINAPI WinMain in place of main.
  • SkulkBaitSkulkBait Join Date: 2003-02-11 Member: 13423Members
    I don't have much experience with VC++, but are you sure you have the right libraries linked in? VC++ probably handles all that for you when you create the project, but it couldn't hurt to check. I believe the one that really matters is libwin32spl.a, but that might be a GCC only thing.
  • pielemuispielemuis Join Date: 2002-01-25 Member: 72Members, NS1 Playtester
    Make sure you started a win32 application and not a console application.
  • HawkeyeHawkeye Join Date: 2002-10-31 Member: 1855Members
    Wish I could help you there. I consider myself an expert in C and C++, but I try to stay away from using windows until I absolutely have to. I do far more work making console type interphase (system("PAUSE"); and system("CLS"); do wonders).
  • Crono5Crono5 Join Date: 2003-07-22 Member: 18357Members
    <!--QuoteBegin-pielemuis+Mar 28 2004, 04:52 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (pielemuis @ Mar 28 2004, 04:52 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Make sure you started a win32 application and not a console application. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
    Well, now I feel smart.

    Hey, at least I wasted peoples time. :\
  • OttoDestructOttoDestruct Join Date: 2002-11-08 Member: 7790Members
    <!--QuoteBegin-Hawkeye+Mar 28 2004, 04:42 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Hawkeye @ Mar 28 2004, 04:42 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Wish I could help you there. I consider myself an expert in C and C++, but I try to stay away from using windows until I absolutely have to. I do far more work making console type interphase (system("PAUSE"); and system("CLS"); do wonders). <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
    Er... so thats how you do pause and clear screen? I've yet to see anything that told me that <!--emo&???--><img src='http://www.unknownworlds.com/forums/html//emoticons/confused.gif' border='0' style='vertical-align:middle' alt='confused.gif' /><!--endemo-->
  • Crono5Crono5 Join Date: 2003-07-22 Member: 18357Members
    Yeah. It's in the stdlib.h file.
  • OttoDestructOttoDestruct Join Date: 2002-11-08 Member: 7790Members
    Well that will help me a lot I guess. I was starting to make a human vs human chess program. I really need to learn windows (as in GUI windows) programming....
  • HawkeyeHawkeye Join Date: 2002-10-31 Member: 1855Members
    Well, I mean okay, if you're writing a chess program, you can't do that using dos. Nor can you make a 3d shooter using dos. Some things you need graphics for. However, I like to stretch the interphase for dos if I can.

    pause and clear allow you to give the illusion of a smooth transition. If you enter in something and hit enter, the screen can immediately switch to something else. In my opinion, the capabilities of a program are more important than the interphase. Especially if you're the only one using.
  • SoulSkorpionSoulSkorpion Join Date: 2002-04-12 Member: 423Members
    edited March 2004
    The word's "interface" <!--emo&;)--><img src='http://www.unknownworlds.com/forums/html//emoticons/wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /><!--endemo-->. Although "interphase" does sound very high tech and awesome.

    ...

    Believe it or not, you can actually invoke message boxes from a console application. You can #include <windows.h>, have your main as a normal int main, and in your code have a call to MessageBox. It'll work.

    Mind you, you do need to make it a windows app if you intend to, well, make windows with it.

    ...

    Avoid using std::system() unless you really have to. The idea is that they make your code less portable; in this case it doesn't make any difference because you're never going to run your code on anything other than your machine, but it's not good practise to get into using platform-specific code without having made provision for it.
  • CreepieCreepie Join Date: 2003-02-19 Member: 13734Members
    edited March 2004
    How have you created your project in MSVC ?

    It sounds like you have got you're missing your MS libraries in the link.
Sign In or Register to comment.