Public Group

# visual C++ 2005

This topic is 5043 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
Did you create the program as a Windows application or as a command-line application? And does it work if you comment out the MessageBox line (just return 0)?

##### Share on other sites
Perhaps the needed import library (user32.lib) is not defined in the project settings.

##### Share on other sites
If your using Visual C++ express 2005 beta it won't build Win32 apps without fiddling, the visual c++ website has instructions to make it work near the bottom of the page.

##### Share on other sites
Quote:
 From MSDN:Function InformationMinimum 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 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  __cplusplusextern "C" {#endif

##### Share on other sites
Windows.h needs to be included first.

##### Share on other sites
Quote:
 Original post by MastabaWindows.h needs to be included first.

uh i tried that and it still gives the same errors

##### Share on other sites
ok i've tried to compile the default program that the compiler makes and its still giving me the first two errors. Does anyone know if this is a problem with vadefs.h?

##### 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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631425
• Total Posts
3000015
×