Archived

This topic is now archived and is closed to further replies.

Locke

Hello World Help (How Embarrassing)

Recommended Posts

After a little while doing dos programs and other forms of programming (mods and the like) I purchased a book on Windows programming. Whenever I try to compile this very simple program: #define WIN32_LEAN_AND_MEAN #include #include int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { MessageBox(NULL, "What''s up world!", "My First Windows Program",MB_OK); return(0); } I always recieve this error: --------------------Configuration: PROG3_2 - Win32 Debug-------------------- Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/hello.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. hello.exe - 2 error(s), 0 warning(s) (This is in Microsoft Visual C++ version 6 by the way) Can anyone help? Thanks in advance, Locke Brendan ''Locke'' Hennessy "I heard life sucks, so that''s why I don''t have one"

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It looks to me as though you are working in a Win32 console app, and not a win32 Application.

To solve this:
1. Create a new workspace using a Win32 Application.
2. Copy and paste your code

OR possibly you have placed your code into a header file (*.h)...

Share this post


Link to post
Share on other sites
I bet when you made a new project, you didn''t make it a Win32 Application. That''s what it sounds like, because _main is a dos thing. If you didn''t make a project, make one by going to File->New Then fill out the dialogue that appears, making sure that you choose Win32 Application. Then add your CPP file to that project.

-Blackstream

Once, a long time ago, I was young and very newbish. Now, I''m much older. I''m still a newbie.

Share this post


Link to post
Share on other sites
You know what''s funny? I consulted a book on programming to figure out your question, and I found the EXACT SAME PROGRAMMING DOWN TO THE WORDS!!! Is that funny or what? Your book is Windows Game Programming for Dummies or Tricks of the Window''s Game Programming Gurus, right? The book that I found the code in, is the Dummies book.

-Blackstream

Once I was young and foolish. Now I''m a little bit older, and I''m still foolish.

Share this post


Link to post
Share on other sites
OK, you shouldn't be embarrased. That's a lot of coding crap to have to do to say 'Hello World'.

I've been programming in C for thirteen years and rarely can I write one single line of code without there being a bug or a syntax error.

I think someone once said that you have to debug even your one line programs.



Edited by - bishop_pass on November 3, 2000 1:38:06 AM

Share this post


Link to post
Share on other sites
Interestingly, if you open up your project''s settings and look at the linker switches, they will include either /SUBSYSTEM:CONSOLE or /SUBSYSTEM:GUI, depending on how you created your project. Now if you delete this switch, VC++ will automatically detect whether your code has a main() or a WinMain(), and perform the appropriate linking steps.

Go figure.

Share this post


Link to post
Share on other sites
While we''re on the subject, how important is it that I can create a window by memory, along with the WinProc, etc...? Just wondering, cuz I spent about a week memorizing (sucessfully, finally!) how to create a window, add resources, and stuff and I started wobdering if I was wasting my time, hehe.

Share this post


Link to post
Share on other sites
quote:
Original post by bishop_pass

I think someone once said that you have to debug even your one line programs.



Thus spake the Master Programmer:

"Though a program be but three lines long, someday it will have to be maintained."


-- The Tao of Programming




Not quite what you had said, but pretty close.

-Ironblayde
 Aeon Software

The following sentence is true.
The preceding sentence is false.


Edited by - Ironblayde on November 3, 2000 12:43:28 AM

Share this post


Link to post
Share on other sites