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

Linker Errors

Started by Enerjak Nov 30, 2007 at 9:00 PM 10 replies 4.4k views
Original Post
Enerjak
Enerjak
I'm still having the damn linker errors when i try to compile with sound. It says that:


1>CSound.obj : error LNK2019: unresolved external symbol "public: long __thiscall CSoundManager::SetPrimaryBufferFormat(unsigned long,unsigned long,unsigned long)" (?SetPrimaryBufferFormat@CSoundManager@@QAEJKKK@Z) referenced in function "public: int __thiscall CSound_Audio::Initialize_DirectAudio(struct HWND__ *)" (?Initialize_DirectAudio@CSound_Audio@@QAEHPAUHWND__@@@Z)
1>CSound.obj : error LNK2019: unresolved external symbol "public: long __thiscall CSoundManager::Initialize(struct HWND__ *,unsigned long)" (?Initialize@CSoundManager@@QAEJPAUHWND__@@K@Z) referenced in function "public: int __thiscall CSound_Audio::Initialize_DirectAudio(struct HWND__ *)" (?Initialize_DirectAudio@CSound_Audio@@QAEHPAUHWND__@@@Z)
1>CSound.obj : error LNK2019: unresolved external symbol "public: __thiscall CSoundManager::CSoundManager(void)" (??0CSoundManager@@QAE@XZ) referenced in function "public: int __thiscall CSound_Audio::Initialize_DirectAudio(struct HWND__ *)" (?Initialize_DirectAudio@CSound_Audio@@QAEHPAUHWND__@@@Z)
1>CSound.obj : error LNK2019: unresolved external symbol "public: long __thiscall CSoundManager::Create(class CSound * *,wchar_t *,unsigned long,struct _GUID,unsigned long)" (?Create@CSoundManager@@QAEJPAPAVCSound@@PA_WKU_GUID@@K@Z) referenced in function "public: class CSound * __thiscall CSound_Audio::LoadSound(wchar_t *)" (?LoadSound@CSound_Audio@@QAEPAVCSound@@PA_W@Z)
1>CSound.obj : error LNK2019: unresolved external symbol "public: long __thiscall CSound::Play(unsigned long,unsigned long,long,long,long)" (?Play@CSound@@QAEJKKJJJ@Z) referenced in function "public: void __thiscall CSound_Audio::PlaySoundW(class CSound *)" (?PlaySoundW@CSound_Audio@@QAEXPAVCSound@@@Z)
1>CSound.obj : error LNK2019: unresolved external symbol "public: long __thiscall CSound::Stop(void)" (?Stop@CSound@@QAEJXZ) referenced in function "public: void __thiscall CSound_Audio::StopSound(class CSound *)" (?StopSound@CSound_Audio@@QAEXPAVCSound@@@Z)
1>C:\Users\DirectX\Documents\Visual Studio 2005\Projects\DirectX 10\Debug\DirectX 10.exe : fatal error LNK1120: 6 unresolved externals
1>Build log was saved at "file://c:\Users\DirectX\Documents\Visual Studio 2005\Projects\DirectX 10\DirectX 10\Debug\BuildLog.htm"
1>DirectX 10 - 7 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========


even though i included the .h files from the DXUT library it still doesn't seem to work. also also here is my code for sound.


//////////////////////////////////////////////////////////////////
//																//
//	Filename:													//
//		CSound.cpp												//
//																//
//	Purpose:													//
//		This is were we initialize our class we created earlier //
//	int CSound.h. This fill is the "heart" of sound playing		//
//																//
//	Date:														//
//		November 26th, 2007										//
//																//
//	Author:														//
//		Rosario Corsini											//
//																//
//////////////////////////////////////////////////////////////////
#pragma warning(disable:4267)
#pragma warning(disable:4312)
#pragma warning(disable:4018)
#pragma warning(disable:4244)
#include "CSound.h"


int CSound_Audio::Initialize_DirectAudio(HWND hwnd)
{
	g_pSoundManager	= new CSoundManager();

	HRESULT result;
	
	//Initialize DirectSound
	result = g_pSoundManager->Initialize(hwnd, DSSCL_PRIORITY);
	if(result != DS_OK)
		return 0;

	result = g_pSoundManager->SetPrimaryBufferFormat(2,22050,16);
	if(result != DS_OK)
		return 0;

	return 1;
}



CSound* CSound_Audio::LoadSound(wchar_t *filename)
{
	HRESULT result;


	result = g_pSoundManager->Create(&sound,filename);
	if(result != DS_OK)
		return 0;

	return sound;
}

void CSound_Audio::PlaySoundW(CSound* sound)
{
	sound->Play();
}

void CSound_Audio::LoopSound(CSound *sound)
{
	sound->Play(0,DSBPLAY_LOOPING);
}

void CSound_Audio::StopSound(CSound *sound)
{
	sound->Stop();
}
.CPP

////////////////////////////////////////////////////////////
//														  //
//	Filename:											  //
//		CSound.h										  //
//														  //
//	Purpose:										      //
//		This file is used to create a class to be able	  //
//	to load sounds, play them, add echo to them, ect.     //
//														  //
//	Date:												  //
//		November 26th, 2007								  //
//														  //
//	Author:												  //
//		Rosario Corsini									  //
//														  //
////////////////////////////////////////////////////////////

//set everything in an #if block

#ifndef CSOUND_H
#define CSOUND_H

#include <SDKsound.h>
#include <SDKwavefile.h>
//#include <nf.h>
//#include <dsound.h>

#pragma comment(lib,"dsound.lib")



//-----------------------------------------------//
//											     //
//	Name:										 //
//		CSound_Audio							 //
//												 //
//	Purpose:									 //
//		Class to make loading sounds easier		 //
//											     //
//-----------------------------------------------//
class CSound_Audio
{
public:
	int		Initialize_DirectAudio(HWND hwnd);
//	int		CreateWave(char filename);
	CSound*	LoadSound(wchar_t *filename);
	void	PlaySound(CSound* sound);
	void	LoopSound(CSound* sound);
	void	StopSound(CSound* sound);
private:
	 CSoundManager* g_pSoundManager;
	 CSound* sound;
	//LPDIRECTSOUND8	g_pDirectSound;					//Direct Sound's primary interface
	//LPDIRECTSOUNDBUFFER	g_pDirectSoundBuffer;	//Creates a sound buffer
	//DSBUFFERDESC	g_pDirectSoundPrimaryBuffer;	//Gets the primary sound buffer
	//WAVEFORMATEX	g_pWaveFormat;					//The wave format used
};

#endif




hopefully you can tell me WTF i'm suppose to do to get the linker errors to stop.
JohnBolton
JohnBolton
Including the header files is not enough. They just describe the libraries' interfaces to the compiler. You need to link in the libraries themselves. In VS, you add the library files to the Project Properties under Linker>Input>Additional Dependencies, or I think you can add them directly to the project.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Fade Ethereal
Fade Ethereal
It looks like youre missing the #includes for your CSoundManager class in your header file.

It doesnt look like this is the problem, but it solved a few DirectX problems for me. Add #pragma comment(lib, "dxguid.lib") after your other lib.
Enerjak
Enerjak
I included dsound, dxguid, dxerr9 and winmm and it still wont work. that's all the libraries the book i'm using tells me to put in. So i don't know
Enerjak
Enerjak
thing is the CSoundManager Class is in SDKsound and i included that in
swiftcoder
swiftcoder
Make sure the .cpp which implements SoundManager is added to your project - those linker errors are telling you that it is not.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Enerjak
Enerjak
I added the SDKsound.cpp to my project, now i get these errors

1>SDKsound.cpp1>c:\program files (x86)\microsoft directx sdk (april 2006)\include\d3dx10tex.h(203) : error C2146: syntax error : missing ';' before identifier 'ResourceType'1>c:\program files (x86)\microsoft directx sdk (april 2006)\include\d3dx10tex.h(203) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int1>c:\program files (x86)\microsoft directx sdk (april 2006)\include\d3dx10tex.h(203) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int1>c:\users\directx\documents\visual studio 2005\projects\directx 10\directx 10\bin\dxut\core\dxutenum.h(266) : error C2039: 'BufferDesc' : is not a member of 'DXGI_SWAP_CHAIN_DESC'1>        c:\program files (x86)\microsoft directx sdk (april 2006)\include\dxgitype.h(331) : see declaration of 'DXGI_SWAP_CHAIN_DESC'1>c:\users\directx\documents\visual studio 2005\projects\directx 10\directx 10\bin\dxut\core\dxutenum.h(266) : error C2228: left of '.Format' must have class/struct/union1>Build log was saved at "file://c:\Users\DirectX\Documents\Visual Studio 2005\Projects\DirectX 10\DirectX 10\Debug\BuildLog.htm"1>DirectX 10 - 5 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========


and i did add DirectX 10 libs to my project and the header files, so what do i do now?
Enerjak
Enerjak
Ok i got it down to 3 errors - (Which don't make any sense to me, but what do I know?)

tge errors are:

1>c:\program files (x86)\microsoft directx sdk (april 2006)\include\d3dx10tex.h(203) : error C2146: syntax error : missing ';' before identifier 'ResourceType'1>c:\program files (x86)\microsoft directx sdk (april 2006)\include\d3dx10tex.h(203) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int1>c:\program files (x86)\microsoft directx sdk (april 2006)\include\d3dx10tex.h(203) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int1>Build log was saved at "file://c:\Users\DirectX\Documents\Visual Studio 2005\Projects\DirectX 10\DirectX 10\Debug\BuildLog.htm"and they all point to this line in d3dx10tex.h:typedef struct _D3DX10_IMAGE_INFO{    UINT                        Width;    UINT                        Height;    UINT                        Depth;    UINT                        ArraySize;    UINT                        MipLevels;    DXGI_FORMAT                 Format;->  D3D10_RESOURCE              ResourceType;    D3DX10_IMAGE_FILE_FORMAT    ImageFileFormat;


any help would be appriciated
Fade Ethereal
Fade Ethereal
Its saying it doesnt know what D3D10_RESOURCE is and is trying to make both that and ResourceType an int variable.

I cant find much info on D3D10_RESOURCE (only one link when I google it) so I dont know what header is needed. Search the DirectX headers for D3D10_RESOURCE and include that header or change the code accordingly.
Enerjak
Enerjak
Ok, managed to get that straighten out, now i get this error:

1>Linking...1>DXUT.obj : error LNK2019: unresolved external symbol __imp__InitCommonControls@0 referenced in function "long __stdcall DXUTInit(bool,bool,wchar_t *,bool)" (?DXUTInit@@YGJ_N0PA_W0@Z)1>C:\Users\DirectX\Documents\Visual Studio 2005\Projects\DirectX 10\Debug\DirectX 10.exe : fatal error LNK1120: 1 unresolved externals1>Build log was saved at "file://c:\Users\DirectX\Documents\Visual Studio 2005\Projects\DirectX 10\DirectX 10\Debug\BuildLog.htm"


It uses the shellAPI so what lib file do i need to include to make that work?

EDIT: I'm starting to think that using DXUT for sound sucks, i should just learn DirectAudio (Though it's always good to use what's already made - sometimes as is the case now)
SiCrane
SiCrane
Here's how you would find out for yourself: Open MSDN. Enter "InitCommonControls" and read the entry for the function. At the very bottom there will be an line that says what import library you need to use, which should be comctl32.lib.
Enerjak
Enerjak
thanks, that worked, sorry for all the stupid posts.

Topic Locked

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

Sign in to reply to this topic.