Jump to content
  • Advertisement
Sign in to follow this  
spirit0306

build error

This topic is 4312 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 have no problems in compiling but when building the program i have an error which says "error LNK2001: unresolved external symbol "bool __cdecl interpretError(long,char *,int)" (?interpretError@@YA_NJPADH@Z)" what library or header file i am missing with this error? Thanks!
#ifndef __AUDIO_H__
#define __AUDIO_H__
typedef unsigned long ulong;



#include <dsound.h>

void fillWaveFormat(WAVEFORMATEX& w,int rate,int bits,int channels);

class audioIn{
	public:
		virtual bool init(int rate,int bits,int channels,int bufsize)=0;
		virtual void quit(void)=0;
		virtual bool start(void)=0;
		virtual void stop(void)=0;
		virtual bool read(void* buf,int size)=0;
		virtual void clear(void)=0;
	};

class dSoundCapture:public audioIn{
	public:
		dSoundCapture();
		~dSoundCapture();
		bool init(int rate,int bits,int channels,int bufsize);
		void quit(void);
		bool start(void);
		void stop(void);
		bool read(void* buf,int size);
		void clear(void);
	private:
		LPDIRECTSOUNDCAPTURE dsCapture;
		LPDIRECTSOUNDCAPTUREBUFFER buffer;
		ulong lastReadPos,bufferSize;
	};

#endif

#include "main.h"

////
//
//
// function to fill waveFormatEx structure
//
//
////

void fillWaveFormat(WAVEFORMATEX& w,int rate,int bits,int channels){
	ZeroMemory(&w,sizeof(WAVEFORMATEX));
	w.wFormatTag = WAVE_FORMAT_PCM;
	w.nChannels = channels;
	w.wBitsPerSample = bits;
	w.nSamplesPerSec = rate;
	w.nBlockAlign = (w.nChannels * w.wBitsPerSample) / 8;
	w.nAvgBytesPerSec = w.nSamplesPerSec * w.nBlockAlign;
	w.cbSize = 0;
	}

////
//
//
// class dSoundCapture
//   an audioIn device using directSound
//
//
////

dSoundCapture::dSoundCapture(){
	dsCapture=NULL;
	buffer=NULL;
	}

dSoundCapture::~dSoundCapture(){
	quit();
	}

bool dSoundCapture::init(int rate,int bits,int channels,int bufsize){
	// attach to directsound capture
	dsCapture=NULL;
	err(DirectSoundCaptureCreate(NULL,&dsCapture,NULL));
	if(dsCapture){
		// create capture buffer
		WAVEFORMATEX w;
		fillWaveFormat(w,rate,bits,channels);
		DSCBUFFERDESC desc;
		ZeroMemory(&desc,sizeof(desc));
		desc.dwSize = sizeof(desc);
		desc.dwBufferBytes = bufsize;
		desc.lpwfxFormat = &w;
		err(dsCapture->CreateCaptureBuffer(&desc,&buffer,NULL));
		if(buffer){
			// double check settings on buffer
			DSCBCAPS caps2; caps2.dwSize=sizeof(caps2);
			buffer->GetCaps(&caps2);
			bufferSize = caps2.dwBufferBytes;
			lastReadPos=0;
			buffer->GetFormat(&w,sizeof(w),NULL);
			if(w.nSamplesPerSec != (DWORD)rate || w.wBitsPerSample != (WORD)bits || w.nChannels != (WORD)channels)
				return false;
			clear();
			}
		else return false;
		}
	else return false;
	return true;
	}

void dSoundCapture::quit(void){
	stop();
	if(buffer) {buffer->Release(); buffer=NULL;}
	if(dsCapture) {dsCapture->Release(); dsCapture=NULL;}	
	}

bool dSoundCapture::start(void){
	if(buffer)
		err(buffer->Start(DSCBSTART_LOOPING));
	return true;
	}

void dSoundCapture::stop(void){
	if(buffer)
		buffer->Stop();
	}

bool dSoundCapture::read(void* buf,int size){
	// what is the read position?
	if(!buffer) return false;
	ulong readPos=0,capturePos=0;
	buffer->GetCurrentPosition(&capturePos,&readPos);
	
	// can we read enough data?
	ulong readEnd = (lastReadPos + size) % bufferSize;
	if((lastReadPos > capturePos && readEnd > capturePos) ||
		(lastReadPos > capturePos && readEnd < lastReadPos && readEnd < readPos) ||
		(lastReadPos < readPos && readEnd < readPos)){
		// read in the data
		ulong size1=0,size2=0;
		void* audio1=NULL,*audio2=NULL;
		buffer->Lock(lastReadPos,size,&audio1,&size1,&audio2,&size2,0);
		if(audio1) memcpy(buf,audio1,size1);
		if(audio2) memcpy((char*)buf+size1,audio2,size2);
		buffer->Unlock(audio1,size1,audio2,size2);		
		
		// move read position so we partially cover previous area
		lastReadPos = (lastReadPos + (size>>1) + (size>>2))
			% bufferSize;
		return true;
		}
	return false;
	}

void dSoundCapture::clear(void){
	// zero the buffer
	if(buffer){
		void* audio1;
		ulong size1;
		buffer->Lock(0,0,&audio1,&size1,NULL,NULL,DSCBLOCK_ENTIREBUFFER);
		ZeroMemory(audio1,size1);
		buffer->Unlock(audio1,size1,NULL,0);
		}
	}

Share this post


Link to post
Share on other sites
Advertisement
Since your code snippet doesn't refer to the function in question anywhere, I susptect it it used elsewhere. From the signature of the function and the increased popularity of MS Visual C++ Express, I suspect you fell into the unicode-trap.

First make sure your project contains a cpp file that actually defines a function called "interpretError", e.g. it defines a body for it. Next, if you find such function, make sure the signatures in both the header and the cpp file match.

This means if the header contains bool interpretError(long, LPCTSTR, int);, double check that the signature of the function in the cpp file is the same.

HTH,
Pat.

PS: This is not a header issue, as you encountered a linker-error, not a compiler error.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!