Sign in to follow this  
noel33

visual C++ 2005

Recommended Posts

i'm trying to start using visual c++ 2005 but i'm having a problem getting even the simplest of my programs to compile. Can someone tell me why this doesn't?
#include <cstdio>
#include <tchar.h>
#include <windows.h>
#include <windowsx.h>
using namespace std;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	MessageBox(NULL,"hello","whoa",MB_OK);
	return 0;
}

i'm getting Source1.obj : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function _WinMain@16

Share this post


Link to post
Share on other sites
Quote:
From MSDN:
Function Information

Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode and ANSI versions on Windows NT, Windows 2000, Windows XP

In other words, make sure that your application is correctly linking with User32.lib.

Share this post


Link to post
Share on other sites
k ive made all the changes the website told me to make but now i'm getting three new errors

c:\Program Files\Microsoft Visual Studio 8\VC\include\vadefs.h(34) : error C2144: syntax error : 'int' should be preceded by ';'

c:\Program Files\Microsoft Visual Studio 8\VC\include\vadefs.h(34) : error C2501: 'z' : missing storage-class or type specifiers

c:\Documents and Settings\Noel.MH-1\My Documents\Visual : error C2871: 'std' : a namespace with this name does not exist

btw for the first two errors here is the line from vadefs.h


#ifdef __cplusplus
extern "C" {
#endif


Share this post


Link to post
Share on other sites
Well, I'm stumped. Looks like your install of 2005 is messed up?

I tested the following code in an empty Win32 project in 2005 Express and it compiled and ran with no problem.


#include <windows.h>
#include <windowsx.h>
#include <cstdio>
#include <tchar.h>
using namespace std;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
MessageBox(NULL,"hello","whoa",MB_OK);
return 0;
}



As you can see, it is your source code with the Windows headers moved to be first.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this