Sign in to follow this  
Fixxer

VC++ 2005 and Old Code

Recommended Posts

Fixxer    100
I've decided I wanted to finally get around to learning direct x, and I have a book that teaches to make a toned down version of a game I hope to one day create. Its a basic version of it, but its the exact engine and style of how I want to make my game. Anyway, Im doing all the exercises, and want to use VC++ 2005. This book uses dx 8 and its code is a bit old. I am getting this error
------ Build started: Project: Example 2, Configuration: Debug Win32 ------
Compiling...
main.cpp
Linking...
main.obj : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function _WinMain@16
C:\Documents and Settings\Owner\Desktop\Programming\Windows Game Programming Book\Chapter 2\Example 2\Debug\Example 2.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Owner\Desktop\Programming\Windows Game Programming Book\Chapter 2\Example 2\Example 2\Debug\BuildLog.htm"
Example 2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


with this code
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <windowsx.h>

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow)
{
	MessageBox(NULL,"There can only be one!!!","My 1st Windows Program", MB_OK | MB_ICONEXCLAMATION);
	return(0);
}


Share this post


Link to post
Share on other sites
ldeej    308
This means that you are not linking against the lib that provides the definition for MessageBox.

What do you have as your linker settings?
Look at the linker command line options on Project Properties and make sure you have the following in the read-only text box:

kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Share this post


Link to post
Share on other sites
Fixxer    100
This is what it says:

/OUT:"C:\Documents and Settings\Owner\Desktop\Programming\Windows Game Programming Book\Chapter 2\Example 2\Debug\Example 2.exe" /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\Example 2.exe.intermediate.manifest" /ERRORREPORT:PROMPT kernel32.lib

Share this post


Link to post
Share on other sites
daerid    354
looks like you'll need to download and install the Platform SDK, as well as the Direct X SDK (If you want to develop DirectX applications).

You can find 'em on MSDN (http://msdn.microsoft.com)

Share this post


Link to post
Share on other sites
Fixxer    100
I re-installed VC++ 2005, and now im getting this error.

------ Build started: Project: Example 2, Configuration: Debug Win32 ------
Linking...
LINK : fatal error LNK1181: cannot open input file 'user32.lib'
Build log was saved at "file://c:\Documents and Settings\Owner\Desktop\Programming\Windows Game Programming Book\Chapter 2\Example 2\Example 2\Debug\BuildLog.htm"
Example 2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Share this post


Link to post
Share on other sites
ldeej    308
When compiling C/C++ code there are two things that happen in the background:

1. Code compilation (Convert your human readable source code into a binary format, result is a bunch of .obj files)
2. Code linking (Putting all the .obj files together to create an .exe, .dll, .lib, etc)

For step 1 your code depends on other code (i.e. windows.h), Visual Studio needs to know where to find depedent files. To get this working set the include directories on your project properties under C++/General/Additional Include Directories. Find on your local file system where windows.h lives and add it to the compiler (C++) include paths.

For step 2 your code depends on other precompiled code (other .objs already generated for you that ship with the platform SDK or with VS), those .objs come in form of .libs (Thing of them as bags of .objs). The linker needs to know where to find them. The platform SDK and Visual Studio should have a folder called lib where a bunch of .lib files live. Add such folders to the Linker options under Linker\General\Additional library directories.

To get the options I am talking about right click on your project and select properties.

Hope this helps

Share this post


Link to post
Share on other sites
Fixxer    100
I added the directory to the lib folder in the platform sdk to the place you said and still same error.

I did everything the video on msdn said to do, and even un installed everything (platform sdk, vc++ 2005 express, direct x sdk) everything to do with programming, and re-installed them, and get the same problem.

Share this post


Link to post
Share on other sites
xengoreth    122
Make sure you have registered the Platform SDK with Visual Studio:

Start->Programs->Microsoft Platform SDK for Windows Server 2003 SP1->Register PSDK Directories with Visual Studio

You shouldn't have to include the SDK headers and libraries manually.

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