Archived

This topic is now archived and is closed to further replies.

DrunkenBastard

Help with LNK2001 error.

Recommended Posts

I am reading TOWGPG and am in chapter 3. I am embedding resources in my .exe. The code for the icon and cursor worke but when I try to play a sound with PlaySound() I get an error. error: --------------------Configuration: IncludingResources - Win32 Debug------------ Compiling... IncludingResources.cpp Linking... IncludingResources.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12 Debug/IncludingResources.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. IncludingResources.exe - 2 error(s), 0 warning(s) ---------------------------------------------------------------- Here is my code:
        
// Includes **************************************************************************************

#define WIN32_LEAN_AND_MEAN

#include <windows.h>		// Include all windows headders


#include <windowsx.h>		// Include useful macros


#include <mmsystem.h>

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include "resource.h"




// Defines ***************************************************************************************


// Windows defines

#define WINDOW_CLASS_NAME "WINCLASS"




// Globals ***************************************************************************************

HINSTANCE ghInstanceApp = NULL;




// Functions *************************************************************************************

LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){

	PAINTSTRUCT ps;
	HDC			hdc;

	switch(msg)
	{

	case WM_CREATE:
		{
			// THIS IS THE LINE THAT GETS ERROR

			PlaySound(MAKEINTRESOURCE(IDR_WAVE1), ghInstanceApp, SND_RESOURCE | SND_SYNC);

			// Return sucess

			return(0);
		}break;

	case WM_PAINT:
		{
			// Validate window

			hdc = BeginPaint(hwnd, &ps);
			// Do all painting

			EndPaint(hwnd, &ps);

			// Return sucess

			return(0);
		}break;

	case WM_DESTROY:
		{
			// Send WM_QUIT message

			PostQuitMessage(0);

			// Return sucess

			return(0);
		}break;

	default: break;

	}// end switch


	// Process any messages not taken care of

	return(DefWindowProc(hwnd, msg, wparam, lparam));

}// end WinProc






// WinMain ***************************************************************************************

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine, int nShowCmd) {

	HWND		hwnd;
	MSG			msg;

	WNDCLASSEX WinClass = {
	WinClass.cbSize	= sizeof(WNDCLASSEX),
	CS_HREDRAW | CS_VREDRAW | CS_OWNDC   | CS_DBLCLKS, // These are some window params

	WinProc,
	0,
	0,
	hInstance,
	LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)),
	LoadCursor(hInstance, MAKEINTRESOURCE(IDC_CURSOR1)),
	(HBRUSH)GetStockObject(BLACK_BRUSH), // This is the background color of the window

	NULL,
	WINDOW_CLASS_NAME,
	LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1))
	};

	ghInstanceApp = hInstance;

	if(!RegisterClassEx(&WinClass))
		return(0);

	if(!(hwnd = CreateWindowEx(NULL, WINDOW_CLASS_NAME,
							   "Basic InSAnE window",
							   WS_OVERLAPPEDWINDOW | WS_VISIBLE, // This is the style of the Window

							   CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
							   NULL, NULL,
							   hInstance,
							   NULL)))
		return(0);

	
	while(true)
	{

		// Test if there is a message in the queue if so get it

		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			
			//Test if this is a quit messaage

			if(msg.message == WM_QUIT)
			{
				break;
			}// end if


			// Translate accelerator keys

			TranslateMessage(&msg);

			//Send the messages to WinProc()

			DispatchMessage(&msg);

		}// end if


		// MAIN GAME PROCESSING GOES HERE *******************************************************

		//GameMain()


	}//end while


	// Return to windows

	return(msg.wParam);

}// end WinMain

  
Useing VC++ 6 on the ResourceView tab I have a "WAVE" node with IDR_WAVE1 under it, and in the FileView tab under Headder Files I have resource.h here is the code for resource.h
              
//{{NO_DEPENDENCIES}}

// Microsoft Developer Studio generated include file.

// Used by Resources.rc

//

#define IDI_ICON1                       101

#define IDC_CURSOR1                     102

#define IDR_WAVE1                       105


// Next default values for new objects

// 

#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        106
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
    
I am stuck here and can't really go on until I figure this out. So any help would be greatly appreciated. [edited by - DrunkenBastard on August 12, 2002 5:31:05 AM]

Share this post


Link to post
Share on other sites