Sign in to follow this  

Linker Error...

This topic is 2588 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

Okay, so I've created the simple beginnings of a library called "Sound Engine Library.lib", using the Win32 Wizard, with Static Library settings, using code that that compiles perfectly as an application (obviously I've removed the main function. This is my library's code:

AudioFileAttributes.h

#ifndef _AUDIO_FILE_ATTRIBUTES_H
#define _AUDIO_FILE_ATTRIBUTES_H

//////////////////////////
//INCLUDED FOR DEBUGGING//
//////////////////////////
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
/////////////////
//END DEBUGGING//
/////////////////


/******************************************************************
*These are necessary includes to use the AudioFileAttributes class*
******************************************************************/

#include <XAudio2.h> //The XAudio2 Core

/*********************************************************************
*This class is to be used WITHIN the Sound Engine to help track files*
*********************************************************************/

namespace GameSoundEngine
{
class AudioFileAttributes
{
friend class SoundEngine;
private:
XAUDIO2_BUFFER_WMA* pWMASoundBuffer; //Dynamic-array for storing xWMA related information in applicable files
DWORD dwAudioSize; //Dynamic-array for storing the wave size--used for specifying buffer length
BYTE* pAudioData; //Dynamic-array for storing the wave data into memory (Given to buffer at play-time)
WAVEFORMATEXTENSIBLE* pAudioFormat; //Dynamic-array for storing the RIFF data of xWMA encoded background audio
public:
//Generic Constructor
AudioFileAttributes();
//Destructor to free memory
~AudioFileAttributes();
};
}

#endif




SoundEngine.h

#ifndef _SOUND_ENGINE_H
#define _SOUND_ENGINE_H

//////////////////////////
//INCLUDED FOR DEBUGGING//
//////////////////////////
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
/////////////////
//END DEBUGGING//
/////////////////



//These are necessary includes to use the Sound Engine
#include <vector> //For Support of the vector STL
#include <list> //For Support of the list STL
#include <XAudio2.h> //The XAudio2 Core
#include "AudioFileAttributes.h" //AudioFileAttributes class is used to hold audio data for the specific file



//Definitions to find the FOURCC Identifiers (Windows is a Little-Endian system)
#define _FOURCC_RIFF 'FFIR'
#define _FOURCC_DATA 'atad'
#define _FOURCC_FMT ' tmf'
#define _FOURCC_WAVE 'EVAW'
#define _FOURCC_XWMA 'AMWX'
#define _FOURCC_DPDS 'sdpd'



// Definition of the SoundEngine class--this is the controller class that manages everything

namespace GameSoundEngine
{
class SoundEngine
{
private:
IXAudio2 * pAudioCore; //A Pointer to the Engine Core. This creates various voices, buffers, etc.
IXAudio2MasteringVoice * pMasteringVoice; //A Pointer to the audio-output device. Buffers are not passed directly, but through other voices first.
IXAudio2SourceVoice * pSourceVoice; //A pointer to the audio-output device. Buffers are sent here to process, then automaticaly passed on.
XAUDIO2_BUFFER SoundBuffer; //Buffer structure containing the address of the wave file in memory and playing attributes
XAUDIO2_VOICE_STATE AudioState; //Holds current state information of the XAudio and Source Voices (((((((CURRENTLY UNUSED)))))))
vector <AudioFileAttributes*> pFileInfo; //Dynamic Array for storing audio file information to be sent into a buffer
list <int> unusedIDs; //Dynamic Array for storing unused pFileInfo IDs after being unloaded from memory
bool isFunctional; //Flag to detect functionability.

public:
SoundEngine();
~SoundEngine();
bool ConvertToSFX(string inputFile, string outputFile, bool deleteOriginalFile = false);
bool ConvertToBRT(string inputFile, string outputFile, bool deleteOriginalFile = false);
int LoadAudioToMemory(LPWSTR fileToOpen);
void PlayAudio(int SOUND_ID, bool doesLoop);
void StopAudio();
bool UnloadAudioFromMemory(int SOUND_ID);
bool IsFunctional();
bool LocateChunk(HANDLE hAudioFile, DWORD fourCC, DWORD & dwChunkSize, DWORD & dwChunkDataPosition);
bool ReadChunk(HANDLE hAudioFile, VOID* buffer, DWORD dwBufferSize, DWORD dwBufferOffset);
bool ListUsedVectors();
};
}
#endif




AudioFileAttributes.cpp

#include "SoundEngine.h"


using namespace GameSoundEngine;

AudioFileAttributes::AudioFileAttributes()// : dwAudioSize(0), pAudioData(NULL), pAudioFormat(NULL), pWMASoundBuffer(NULL)
{
cout<<setfill(' ')<<right<<setw(50)<<"Audio File Attributes class initialized\n\n";
}

AudioFileAttributes::~AudioFileAttributes()
{
cout<<setfill(' ')<<right<<setw(50)<<"Deleting Audio File Attributes class from memory\n";

if (pAudioFormat)
{
cout<<setfill('.')<<left<<setw(50)<<"pAudioFormat memory deallocating";
delete pAudioFormat;
cout<<"Success!\n";
}

if (pAudioData)
{
cout<<setfill('.')<<left<<setw(50)<<"pAudioData memory deallocating";
delete pAudioData;
cout<<"Success!\n";
}

if (pWMASoundBuffer)
{
cout<<setfill('.')<<left<<setw(50)<<"pWMASoundBuffer memory deallocating";
delete pWMASoundBuffer;
cout<<"Success!\n";
}

cout<<setfill(' ')<<right<<setw(50)<<"Audio File Attributes class deleted!\n\n";
}




SoundEngine.cpp

#include "SoundEngine.h"
using namespace GameSoundEngine;

SoundEngine SoundManager;



/*********************************************************************
*Class Constructor to Initialize the XAudio2 Core and Mastering Voice*
*********************************************************************/

SoundEngine::SoundEngine() : pAudioCore(NULL), pMasteringVoice(NULL), pSourceVoice(NULL), SoundBuffer(), isFunctional(FALSE), pFileInfo(), unusedIDs()
{

cout<<setfill(' ')<<right<<setw(50)<<"Constructing Sound Engine\n";


/*********************************
*Initializing COM for this thread*
*********************************/

cout<<setfill('.')<<left<<setw(50)<<"COM initializing";
CoInitializeEx(NULL, COINIT_MULTITHREADED);
cout<<"Success!\n";


/*************************
*Creating the XAudio Core*
*************************/

cout<<setfill('.')<<left<<setw(50)<<"Creating Audio Core";
if (S_OK != XAudio2Create(&pAudioCore, //Store the address of the XAudo2 core, at THIS address
0, //No XAUDIO2_DEBUG_ENGINE flag needs to be set Don't want it
XAUDIO2_DEFAULT_PROCESSOR)) //This flag tells XAudio2 to use it's default processor, rather than specifying one
{
cout<<"\nFail!\n\n"; //Error if we failed to create the XAudio2 Core
return;
}
cout<<"Success!\n";


/******************************************
*Creating the Master voice used for output*
******************************************/

cout<<setfill('.')<<left<<setw(50)<<"Creating Master Voice";
if (FAILED(pAudioCore->CreateMasteringVoice(&pMasteringVoice, //Store the Mastering Voice address so that it's settings can be modified if needed
XAUDIO2_DEFAULT_CHANNELS, //Number of audio channels to use. Must be <= XAUDIO2_MAX_AUDIO_CHANNELS
XAUDIO2_DEFAULT_SAMPLERATE, //Sample rate to use. <= XAUDIO2_MAX_SAMPLERATE, >= XAUDIO2_MIN_SAMPLERATE, & multiple of XAUDIO2_QUANTUM_DENOMINATOR
0, //No flags should be set on the Mastering Voice
0, //Set this to 0 for XAudio2 to use the global default audio-output device
NULL))) //May pass a pointer to an XAUDIO2_EFFECT_CHAIN structure, or NULL for no effects
{
cout<<"\nFail!\n\n"; //Error if we failed to create the Mastering Voice
pAudioCore->Release();
return;
}
cout<<"Success!\n";


cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine Constructed!\n\n";
isFunctional = TRUE;
}


/*********************************************************************
*Class Deconstructor to clear Audio and Engine components from memory*
*********************************************************************/

SoundEngine::~SoundEngine()
{
cout<<setfill(' ')<<right<<setw(50)<<"Destructing sound Engine\n";

if (pSourceVoice)
{
cout<<setfill('.')<<left<<setw(50)<<"Source Voice silenced";
pSourceVoice->DestroyVoice();
cout<<"Success!\n";
}

if (pMasteringVoice)
{
cout<<setfill('.')<<left<<setw(50)<<"Mastering Voice silenced";
pMasteringVoice->DestroyVoice();
cout<<"Success!\n";
}

if (!pFileInfo.empty())
{
cout<<setfill('.')<<left<<setw(50)<<"Erasing File Info vector";
pFileInfo.clear();
cout<<"Success!\n";
}

if (!unusedIDs.empty())
{
cout<<setfill('.')<<left<<setw(50)<<"Erasing Unused ID list";
unusedIDs.clear();
cout<<"Success!\n";
}

if (pAudioCore)
{
cout<<setfill('.')<<left<<setw(50)<<"Audio Core shutting down";
pAudioCore->Release();
cout<<"Success!\n";
}


cout<<setfill('.')<<left<<setw(50)<<"COM unitializing";
CoUninitialize();
cout<<"Success!\n";

cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine Destructed!\n\n";
}


/******************************************************
*Load a Sound Effect File into a sound buffer for play*
******************************************************/

int SoundEngine::LoadAudioToMemory(LPWSTR fileToOpen)
{
if (isFunctional) //Only proceed if Sound Engine is functional
{
cout<<setfill(' ')<<right<<setw(50)<<"Loading Audio Into Memory"<<endl;
/**********************
*Variable Declarations*
**********************/

DWORD dwChunkSize;
DWORD dwChunkPosition;


/********************************************
*Create a handle to the specified audio file*
********************************************/

cout<<setfill('.')<<left<<setw(50)<<"Creating Audio file handle";
HANDLE hAudioFile = CreateFileW(fileToOpen, //File Name
GENERIC_READ, //Access-level to file
FILE_SHARE_READ, //Share-mode (share with child processes/threads)
NULL, //SECURITY_ATTIBUTES struct... Not needed here
OPEN_EXISTING, //Open existing file
NULL, //Flags.. NULL
NULL); //File Template for creating new file... NULL
if (hAudioFile == INVALID_HANDLE_VALUE) //Error out if failed to make a file handle
{
cout<<"Fail!\n";
return 0;
}
cout<<"Success!\n";


/*********************************************************************
*Create a new element in the FileAttribute vector. Prepare for data!*
*********************************************************************/

cout<<setfill('.')<<left<<setw(50)<<"Creating pFileInfo element";
int fileInfoElement = 0;
if (!unusedIDs.empty())
{
fileInfoElement = unusedIDs.front() - 1;
unusedIDs.pop_front();
pFileInfo[fileInfoElement] = new AudioFileAttributes;
} else {
pFileInfo.push_back(new AudioFileAttributes);
fileInfoElement = (int) pFileInfo.size() - 1;
}
cout<<"Success!\n";

/******************************
*Locate File Format Data Chunk*
******************************/

if (!LocateChunk(hAudioFile, _FOURCC_FMT, dwChunkSize, dwChunkPosition)) //Locate the Format using its FourCC Identification code
{
cout<<"Failed!\n"; //Error out if failed
return 0;
}


/**************************************************
*Read located File Format data into a vector array*
**************************************************/

pFileInfo[fileInfoElement]->pAudioFormat = new WAVEFORMATEXTENSIBLE;
if (!ReadChunk(hAudioFile,
pFileInfo[fileInfoElement]->pAudioFormat,
dwChunkSize,
dwChunkPosition)) //Store Format Data into the new element
{
cout<<"Failed!\n"; //Or error if failed
return 0;
}


/************************
*Locate Audio Data chunk*
************************/

if (!LocateChunk(hAudioFile, _FOURCC_DATA, dwChunkSize, dwChunkPosition)) //Locate Audio Data using its FourCC Idenfication code
{
cout<<"Failed!\n"; //Error out if failed
return 0;
}


/*******************************************
*Read located Audio Data into a vector arry*
*******************************************/

pFileInfo[fileInfoElement]->pAudioData = new BYTE[dwChunkSize]; //Add new element to the Audio Data Vector Array
if(!ReadChunk(hAudioFile,
(void*) pFileInfo[fileInfoElement]->pAudioData,
dwChunkSize,
dwChunkPosition))
{
cout<<"Failed!\n"; //Error out if failed
return 0;
}


/*********************************************
*Save the Data size into a third vector array*
*********************************************/

cout<<setfill('.')<<left<<setw(50)<<"Storing Audio Size";
pFileInfo[fileInfoElement]->dwAudioSize= dwChunkSize;
cout<<"Success!\n";


/**************************************************
*If this was a xWMA Format file, locate DPDS chunk*
**************************************************/

if ((pFileInfo[fileInfoElement]->pAudioFormat->Format.wFormatTag == WAVE_FORMAT_WMAUDIO2) ||
(pFileInfo[fileInfoElement]->pAudioFormat->Format.wFormatTag == WAVE_FORMAT_WMAUDIO3))
{
if (!LocateChunk(hAudioFile, _FOURCC_DPDS, dwChunkSize, dwChunkPosition)) //Locate DPDS using its FourCC Idenfication code
{
cout<<"Failed!\n"; //Error out if failed
return 0;
}


/**********************************************
*And then read located DPDS into a vector arry*
**********************************************/

pFileInfo[fileInfoElement]->pWMASoundBuffer = new XAUDIO2_BUFFER_WMA; //Add new element to the WMA Buffer Vector Array
pFileInfo[fileInfoElement]->pWMASoundBuffer->pDecodedPacketCumulativeBytes = new UINT32[dwChunkSize];
if(!ReadChunk(hAudioFile, (void*)pFileInfo[fileInfoElement]->pWMASoundBuffer->pDecodedPacketCumulativeBytes, dwChunkSize, dwChunkPosition))
{
cout<<"Failed!\n"; //Error out if failed
return 0;
}
pFileInfo[fileInfoElement]->pWMASoundBuffer->PacketCount = dwChunkSize;
} else {
pFileInfo[fileInfoElement]->pWMASoundBuffer = new XAUDIO2_BUFFER_WMA;
memset(pFileInfo[fileInfoElement]->pWMASoundBuffer, 0, sizeof(XAUDIO2_BUFFER_WMA));
}
cout<<setfill(' ')<<right<<setw(50)<<"Audio Loaded into Memory!\n\n";
return (int) pFileInfo.size(); //Return the vector position for use in SOUND_IDs
} else {
cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine isn't functional!\n\n";
return 0;
}
}

/***************************************************
*Play a Sound Effect File that's loaded into memory*
***************************************************/

void SoundEngine::PlayAudio(int SOUND_ID, bool doesLoop = false)
{
if (isFunctional)
{
cout<<setfill(' ')<<right<<setw(50)<<"Attempting to Play Audio from Memory!\n";
cout<<setfill('.')<<left<<setw(50)<<"Creating Source Voice";
if (FAILED(pAudioCore->CreateSourceVoice(&pSourceVoice, (WAVEFORMATEX*) this->pFileInfo[SOUND_ID -1]->pAudioFormat)))
{
cout<<"Failed!\n";
return;
}
cout<<"Success!\n";

cout<<setfill('.')<<left<<setw(50)<<"Sending Audio Information to Buffer";
SoundBuffer.AudioBytes = pFileInfo[SOUND_ID - 1]->dwAudioSize;
SoundBuffer.pAudioData = pFileInfo[SOUND_ID - 1]->pAudioData;
SoundBuffer.Flags = XAUDIO2_END_OF_STREAM;
if (doesLoop)
{
SoundBuffer.LoopCount = XAUDIO2_LOOP_INFINITE;
}
cout<<"Success!\n";

cout<<setfill('.')<<left<<setw(50)<<"Submitting Buffer to Source Voice";
if (FAILED(pSourceVoice->SubmitSourceBuffer(&SoundBuffer, pFileInfo[SOUND_ID - 1]->pWMASoundBuffer)))
{
cout<<"Failed!\n";
return;
}
cout<<"Success!\n";

cout<<setfill('.')<<left<<setw(50)<<"Playing Audio";
if (FAILED(pSourceVoice->Start(0, XAUDIO2_COMMIT_NOW)))
{
cout<<"Failed!\n";
return;
}
cout<<"Success!\n";
cout<<setfill(' ')<<right<<setw(50)<<"Playing Audio!!!\n\n";
return;
} else {
cout<<setfill(' ')<<left<<"Error: Engine failed to properly construct. Continuing in silence\n\n";
return;
}
}


/*******************************************************
*Located specified Chunk in a RIFF formatted audio file*
*******************************************************/

bool SoundEngine::LocateChunk(HANDLE hAudioFile, DWORD fourCC, DWORD & dwChunkSize, DWORD & dwChunkDataPosition)
{
if (isFunctional)
{
/******************
*Declare variables*
******************/

DWORD dwChunkType; //Gets the FOURCC of the chunk
DWORD dwChunkDataSize; //Gets the DWORD that holds the chunk size
DWORD dwRIFFDataSize = 0; //The size of hte RIFF data size
DWORD dwFileType; //If read the RIFF chunk, this holds the first 4-bytes of data declaring FILE type (WAVE or XWMA)
DWORD bytesRead = 0; //Amount of bytes read.
DWORD dwOffset = 0; //Offset further Chunks by this amount.
DWORD dwRead; //Needed in synchronous file-reading to detect bytes read


/**************************
*initializing file pointer*
**************************/

cout<<setfill('.')<<left<<setw(50)<<"Setting file pointer to beginning";
if (INVALID_SET_FILE_POINTER == SetFilePointer(hAudioFile, 0, NULL, FILE_BEGIN)) //File Handle, Lo-Word Distance to Move, Hi-Word, Position Flag
{
cout<<"Failed!\n"; //Error out if fail
return false;
}
cout<<"Success!\n";


/*****************************************************
*Infinite Loop to read the type and size of the chunk*
*****************************************************/

while (TRUE)
{
cout<<setfill('.')<<left<<setw(50)<<"Storing Chunk Type";
if (0 == ReadFile(hAudioFile, &dwChunkType, sizeof(DWORD), &dwRead, NULL)) //File Handle, ChunkType buffer, Amount to Read, Byte Counter, NULL
{
cout<<"Failed!\n"; //Error out if fail
return false;
}
cout<<"Success!\n";
cout<<setfill('.')<<left<<setw(50)<<"Storing Chunk Size";
if (0 == ReadFile(hAudioFile, &dwChunkDataSize, sizeof(DWORD), &dwRead, NULL)) //File Handle, ChunkSize buffer, Amount to Read, Byte Counter, NULL
{
cout<<"Failed!\n"; //Error out if fail
return false;
}
cout<<"Success!\n";


/***************************************************************
*Switch statement to detect whether we read the RIFF chunk data*
***************************************************************/

cout<<setfill('.')<<left<<setw(50)<<"Detecting data read";
switch (dwChunkType) //Read the ChunkType DWORD
{
case _FOURCC_RIFF: //Case DWORD is equal to #defined 'FFIR'
dwRIFFDataSize = dwChunkDataSize; //then copy this DataSize to the RiffData Size variable
dwChunkDataSize = 4; //Set dwChunkDataSize to 4?
if(0 == ReadFile(hAudioFile, &dwFileType, sizeof(DWORD), &dwRead, NULL)) //File Handle, FileType buffer, Amount to Read, Byte Counter, NULL
{
cout<<"Failed!\n"; //Error out if fail
return false;
}
cout<<"Success!\n";
break;

default: //DEFAULT (if not equal to #defined 'FFIR' constant
if(INVALID_SET_FILE_POINTER == SetFilePointer(hAudioFile, //File Handle
dwChunkDataSize, //Amount to move (past the data)
NULL, //Hi-DWord = NULL
FILE_CURRENT)) //Start from current file-pointer location
{
cout<<"Failed!\n"; //Error out if fail
return false;
}
cout<<"Success!\n";
}


/**********************
*Prepare offset Amount*
**********************/

dwOffset += sizeof(DWORD) * 2; //dwChunkType and dwChunkSize are DWORDs... so prepare to offset by 2 DWORDS


/******************************************************************************************
*Finish up this iteration of the loop by detecting if we should continue or return a value*
******************************************************************************************/

if (dwChunkType == fourCC) //If this cunk type is the FourCC value passed to the method
{
cout<<setfill('.')<<left<<setw(50)<<"Returning Requested Data";
dwChunkSize = dwChunkDataSize; //Then save the size of the chunk to the DW address passed
dwChunkDataPosition = dwOffset; //And the location to the other DW address passed, as well
cout<<"Success!\n";
break; //Exit our infinite loop
}

dwOffset += dwChunkDataSize; //Otherwise, increase the dwOffset value by the Chunk data size for use in the next iteration

if(bytesRead >= dwRIFFDataSize) //If RIFFdataSize < 0, fail
{
cout<<setfill(' ')<<right<<setw(50)<<"File contains no RIFF format!\n\n";
return false;
}
}
return true;
} else {
cout<<"Sound Engine isn't functional!\n\n";
return false;
}
}


/***************************************************************************
*Read a previously located chunk into a buffer for use in playing the audio*
***************************************************************************/

bool SoundEngine::ReadChunk(HANDLE hAudioFile, VOID* buffer, DWORD dwBufferSize, DWORD dwBufferOffset)
{
if (isFunctional)
{
DWORD dwBytesRead;
cout<<setfill('.')<<left<<setw(50)<<"Setting file pointer";
if (INVALID_SET_FILE_POINTER == SetFilePointer(hAudioFile, dwBufferOffset, NULL, FILE_BEGIN))
{
cout<<"Failed!\n";
return false;
} else {
cout<<"Success!\n";
cout<<setfill('.')<<left<<setw(50)<<"Reading chunk data";
if (0 == ReadFile(hAudioFile, buffer, dwBufferSize, &dwBytesRead, NULL))
{
cout<<"Failed!\n";
return false;
} else {
cout<<"Success!\n";
return true;
}
}
} else {
cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine not functional!\n\n";
return false;
}
}


/**************************************
*Returns isFunctional boolean variable*
**************************************/

bool SoundEngine::IsFunctional()
{
return isFunctional;
}


/*******************************************************************
*Copy the first argument and rename the file to the second argument*
*******************************************************************/

bool SoundEngine::ConvertToSFX(string inputFile, string outputFile, bool deleteOriginalFile)
{


/*********************************************************
*Build the instruction string to send to the command line*
*********************************************************/

if (isFunctional)
{
cout<<setfill(' ')<<right<<setw(50)<<"Converting Audio to SFX\n";
cout<<setfill('.')<<left<<setw(50)<<"Copying file to SFX format";
if (0 == CopyFileA(inputFile.data(), outputFile.data(), FALSE)) //Attempt to copy file to correct extension
{
cout<<"Failed!\n";
cout<<setfill(' ')<<right<<setw(50)<<"Conversion failed!\n\n"; //Error out if fail
return false;
} else { //If copy was successful
cout<<"Success!\n";
if (deleteOriginalFile) //Check to see if user wants original deleted
{
cout<<setfill('.')<<left<<setw(50)<<"Deleting original Audio";
if (DeleteFileA(inputFile.data())) //If they do, try to delete the file
cout<<"Success!\n";
else
{
cout<<"Failed!\n";
cout<<setfill(' ')<<right<<setw(50)<<"Conversion failed!\n\n"; //Error out if deletion failed
return false;
}
}
cout<<setfill(' ')<<right<<setw(50)<<"Audio file converted into SFX format!\n\n"; //If copy (and delete, if applicable) succeeded, SUCCESS IS OURS!!!!!!
return true;
}
} else {
cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine isn't functional!\n\n";
return false;
}
}


/**********************************************************************************************
*Encode the first argument with xWMA and export wtih the filename equal to the second filename*
**********************************************************************************************/

bool SoundEngine::ConvertToBRT(string inputFile, string outputFile, bool deleteOriginalFile)
{
if (isFunctional)
{
/*********************************************************
*Build the instruction string to send to the command line*
*********************************************************/

cout<<setfill(' ')<<right<<setw(50)<<"Converting Audio to BKG\n";
cout<<setfill('.')<<left<<setw(50)<<"Copying file to BKG format";
string commandLine = "\"C:\\Program Files (x86)\\Microsoft DirectX SDK (June 2010)\\Utilities\\Bin\\x86\\xWMAEncode.exe\" -b 192000 ";
commandLine = commandLine + inputFile;
commandLine = commandLine + " ";
commandLine = commandLine + outputFile;


/********************************************
*Process instruction string via command line*
********************************************/

if (0 != system(commandLine.data())) //Process instructions through commend line
{
cout<<"Failed!\n";
cout<<setfill(' ')<<right<<setw(50)<<"Conversion failed!\n\n"; //Error out if failed
return false;
} else { //Otherwise, if it was successful, check deleteOriginalFile boolean
cout<<"Success!\n";
if (deleteOriginalFile) //if user wants original deleted
{
cout<<setfill('.')<<left<<setw(50)<<"Deleting original Audio";
if (DeleteFileA(inputFile.data())) //Try to delete the file
cout<<"Success!\n";
else
{
cout<<"Failed!\n";
cout<<setfill(' ')<<right<<setw(50)<<"Conversion failed!\n\n"; //Error out if deletion failed
return false;
}
}
cout<<"Audio file converted into BKG format!\n\n"; //If conversion (and delete, if applicable) succeeded, SUCCESSS!!!!!!!
return true;
}
} else {
cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine isn't functional!\n\n";
return false;
}
}

/******************************************************************************************
*This is used to erase a single audio file from memory, without deleting the entire vector*
******************************************************************************************/

bool SoundEngine::UnloadAudioFromMemory(int SOUND_ID)
{
if (isFunctional)
{
cout<<setfill(' ')<<right<<setw(50)<<"Unloading Audio from Memory\n";
cout<<setfill('.')<<left<<setw(50)<<"Deleting Audio from Vector";
delete pFileInfo[SOUND_ID - 1];
cout<<"Success!"<<endl;
cout<<setfill('.')<<left<<setw(50)<<"Adding Unused ID to List";
unusedIDs.push_back(SOUND_ID);
cout<<"Success!"<<endl;
cout<<setfill(' ')<<right<<setw(50)<<"Audio Unloaded!\n\n";
return true;
} else {
cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine isn't functional!\n\n";
return false;
}
}

/*************************************
*Display Used Vectors and Their Sizes*
*************************************/

bool SoundEngine::ListUsedVectors()
{
if(isFunctional)
{
cout<<setfill(' ')<<right<<setw(50)<<"Checking Used Vectors and Sizes"<<endl;
cout<<setfill(' ')<<left<<setw(25)<<"Index";
cout<<"Size"<<endl;
for(int index(0); index < pFileInfo.size(); index++)
{
cout<<setfill(' ')<<left<<setw(25)<<index;
cout<<pFileInfo[index]->dwAudioSize<<" bytes"<<endl;
}
cout<<setfill(' ')<<right<<setw(50)<<"Vector checked!\n\n";
return true;
} else {
cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine Isn't Functional!\n\n";
return false;
}
}

void SoundEngine::StopAudio()
{
if (isFunctional)
{
pSourceVoice->Stop();
} else {
cout<<setfill(' ')<<right<<setw(50)<<"Sound Engine isn't functional!\n\n";
}
}




NOW... Like I said, if I set for an EXE compile and add a main function, this compiles are runs correctly. It even compiles error-free in *.lib format, but when trying to use the new library with this simple code:

Source.cpp

#include <SoundEngine.h>
#include <AudioFileAttributes.h>

using namespace GameSoundEngine;
void main()
{
cout<<"Testing Engine\n";
SoundEngine* SoundManager = new SoundEngine;
SoundManager->LoadAudioToMemory(L"1.wav");
SoundManager->PlayAudio(1, false);

int counter = 0;
while (counter == 0)
{
cout<<"Enter number: ";
cin>>counter;
}
SoundManager->UnloadAudioFromMemory(1);
delete SoundManager;
return;
}




I get these errors:

Error 1 error LNK2001: unresolved external symbol "public: bool __thiscall GameSoundEngine::SoundEngine::UnloadAudioFromMemory(int)" (?UnloadAudioFromMemory@SoundEngine@GameSoundEngine@@QAE_NH@Z) C:\Users\Hollow\Documents\Visual Studio 2010\Projects\Trial\Source.obj

Error 2 error LNK2001: unresolved external symbol "public: void __thiscall GameSoundEngine::SoundEngine::PlayAudio(int,bool)" (?PlayAudio@SoundEngine@GameSoundEngine@@QAEXH_N@Z) C:\Users\Hollow\Documents\Visual Studio 2010\Projects\Trial\Source.obj

Error 3 error LNK2001: unresolved external symbol "public: int __thiscall GameSoundEngine::SoundEngine::LoadAudioToMemory(wchar_t *)" (?LoadAudioToMemory@SoundEngine@GameSoundEngine@@QAEHPA_W@Z) C:\Users\Hollow\Documents\Visual Studio 2010\Projects\Trial\Source.obj

Error 4 error LNK2001: unresolved external symbol "public: __thiscall GameSoundEngine::SoundEngine::~SoundEngine(void)" (??1SoundEngine@GameSoundEngine@@QAE@XZ) C:\Users\Hollow\Documents\Visual Studio 2010\Projects\Trial\Source.obj

Error 5 error LNK2001: unresolved external symbol "public: __thiscall GameSoundEngine::SoundEngine::SoundEngine(void)" (??0SoundEngine@GameSoundEngine@@QAE@XZ) C:\Users\Hollow\Documents\Visual Studio 2010\Projects\Trial\Source.obj

Error 6 error LNK1120: 5 unresolved externals C:\Users\Hollow\Documents\Visual Studio 2010\Projects\Trial\Release\Trial.exe







I have no idea what's going on. Admittedly, this is the first lib I've ever tried to create, so please don't crucify me if I'm overlooking something completely basic--I believe I've followed directions to the letter.

Thank you for your help!

Share this post


Link to post
Share on other sites
Assuming you are using a VS compiler (which you might want to mention?) Make sure that your new library is added under the library dependencies along with its path.

Share this post


Link to post
Share on other sites
This is a pretty rudimentary question, but have you actually included the lib in your project settings? It's not enough to just include the header file.

Properties -> Linker -> Input -> Additional Dependencies

Share this post


Link to post
Share on other sites
Yes, the full path is included in the Library Path in the Propert Page. Filename is included in the Additional Dependencies in the Linker options.

And, I'm using Visual Studio 2010.

Share this post


Link to post
Share on other sites

This topic is 2588 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