Hello World Help (How Embarrassing)
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"
Brendan ''Locke'' Hennessy"I heard life sucks, so that''s why I don''t have one"
I think you have created a win32 console project instead of a Win32 App project.
..
..
November 03, 2000 12:08 AM
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)...
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)...
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.
-Blackstream
Once, a long time ago, I was young and very newbish. Now, I''m much older. I''m still a newbie.
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
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.
-Blackstream
Once I was young and foolish. Now I''m a little bit older, and I''m still foolish.
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Thank you so much for all your help, it works fine now =)
Brendan ''Locke'' Hennessy
"I heard life sucks, so that''s why I don''t have one"
Brendan ''Locke'' Hennessy
"I heard life sucks, so that''s why I don''t have one"
Brendan ''Locke'' Hennessy"I heard life sucks, so that''s why I don''t have one"
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
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
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
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.
Go figure.
Tom Nuydens delphi3d@gamedeveloper.org www.gamedeveloper.org/delphi3d
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.
Peon
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
"Your superior intellect is no match for our puny weapons!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement