It should tell you what the unresolved external is. can you provide that additional information?
I am guessing that is is "main" or some variation thereof, and you have failed to specify your project as a Windows Application, rather than a console one. If you are unsure how to do this, I could probably help you with Visual Studio or Code::Blocks. What IDE are you using?
Hmm... I've just successfully built your code in a new empty Win32 project in Visual Studio 2010.
Try setting WINDOWS as the Subsystem setting in the linker settings (Project -> Properties -> Configuration Properties -> Linker -> System -> Subsystem). If you are using both Debug and release configurations, remember to change it for both.
--------------------------
On a side note, consider wrapping your string literals with _T( ) when passing them to WinAPI functions.
MessageBox could turn into MessageBoxA (ASCII) or MessageBoxW (Unicode) depending on project settings. You are passing it ASCII strings, so if you were to change your project to Unicode, it would't compile.
If your project is using ASCII strings, _T() resolves to nothing during preprocessing. If your project is Unicode, it resolves to L, which makes your string literals Unicode. Thus it means your program will compile as ASCII and Unicode. Just a small tip :)
This is what I was talking about in my previous post. It is because MessageBox is resolving to MessageBoxW (Unicode) not MessageBoxA (ASCII). (MessageBox itself is a macro...)
As you are getting MessageBoxW, you must pass Unicode literals. But the safest thing to do is #include the <tchar.h> header and wrap the string literals you pass to it in _T(), which will turn them into Unicode where necessary, but it won't if it's unnecessary. A long term and durable fix :)
Oh dude your last post wasnt there when i wrote my last post lol.
when you said
"If you are using both Debug and release configurations, remember to change it for both."
I changed the subsystem setting to WINDOWS, but how do i do it for Debug and relase configurations?
EDIT: never mind i figured that part out. BUT i still need to write it as 'MessageBoxA'. In the book im reading they dont have to write it like that. And they dont add in all those includes and _T's or whatever they type it in exactly the way i have it writtin in the OP
When you're in the project settings dialog, at the top on the left there should be a dropdown to change between Debug and Release. You can also select "All Configurations" to allow you to apply a setting to both configurations at once.
To build your project in a particular configuration, you select it from the dropdown on one of the toolbars at the top of the screen (not in the properties pages, but in the main IDE window).
Don't put the A at the end. As I said, MessageBox depends on project settings, but if you put your string literals inside _T(): "hello world!" -> _T("hello world!") then the problem is solved in the best possible way and you can leave MessageBox without the A. read my previous posts for some explanation as to why this is necessary.
Sorry, I was thinking about something else actually... You can use the A one if you want. Just note that you won't be able to do do that if you want to display a unicode string.
Well, instead of typing a string literal: "some string"
type a wide string literal: L"some Unicode string"
or better yet, do what has been recommended: _T("some string that may or may not be Unicode") just make sure that you #include <tchar.h> after the windows.h include
According to Disch, typing the "L" is not a good option with the Windows API, because all the code would break were you to change your project to non Unicode.
Therefore, either to the A, or (better still, IMO), use the _T( ). Of course, you should only do this to the string literals which you pass to WinAPI functions.