Skip to main content
GameDev.net gamedev.net
🔒 Locked

VC++ 2005 and Old Code

Started by Fixxer Apr 21, 2006 at 5:08 PM 11 replies 1.1k views
Original Post
Fixxer
Fixxer
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);
}


ldeej
ldeej
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
Fixxer
Fixxer
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
daerid
daerid
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)
daerid@gmail.com
Fixxer
Fixxer
Ok, did that and used the video to show me how to set it up.

Now it says there is no windows.h
TFS_Waldo
TFS_Waldo
Maybe you should make sure that Visual Studio's Include Directories include the location of the "windows.h" file. =)
:==- Why don't the voices just leave me alone?! -==:
Fixxer
Fixxer
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 ==========
ldeej
ldeej
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
Fixxer
Fixxer
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.
xengoreth
xengoreth
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.
Fixxer
Fixxer
I fixed it.

I added User32.lib and Gdi32.lib into the additional section of the linker input.
jflanglois
jflanglois
You didn't read this in its entirety, did you.
Fixxer
Fixxer
Ah thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.