-
Hello World in Windows
A C++ dosprogrammer who's entering the beautiful world of windowsprogramming (I wanted more memory to my programs) :
I got Microsoft Visual C++, today and wanted to make the simpliest program in the world: Hello World!
So I wrote:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
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);
}
But the **** wouldn't work, I could compile it, but not build an "exe-file" of it!
It said:
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Ok, probably a verry easy problem, but I'm a newbie in
Visual C++6, and my world would be a lot easier if someone could help me!
Rock on!
-
Have you set up the correct type of project?
Looks like the compiler is looking for main() i.e. it is expecting a console application. When you start a new project you need to select win32 application or whatever the option is.
-
VC++ takes a bit of getting used to, as does Win32 programming. If you like, this is about as basic a Win32 "Hello World" as you can do. Look up the API routines in the excellent help. If(when) you get stuck, ask here. Good luck man.