Sign in to follow this  

Linker Errors

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I added the SDKsound.cpp to my project, now i get these errors



1>SDKsound.cpp
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-int
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-int
1>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/union
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 - 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?

Share this post


Link to post
Share on other sites
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-int
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-int
1>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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 externals
1>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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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