After looking around for various sound API libraries, I have decided to use FMOD for the time being.
Problem is that whenever I try to compile one of the code examples, I get the following errors:
objReleasemain.o:main.cpp|| undefined reference to `FMOD::System::getVersion(unsigned int*)@8'|
objReleasemain.o:main.cpp|| undefined reference to `FMOD::System::init(int, unsigned int, void*)@16'|
objReleasemain.o:main.cpp|| undefined reference to `FMOD::System::createSound(char const*, unsigned int, FMOD_CREATESOUNDEXINFO*, FMOD::Sound**)@20'|
objReleasemain.o:main.cpp|| undefined reference to `FMOD::Sound::setMode(unsigned int)@8'|
The code example that I am using being this:
#include <D:GamesFMOD Programmers API Win32apiincfmod.hpp>
#include <D:GamesFMOD Programmers API Win32apiincfmod_errors.h>
#include <sstream>
#include <windows.h> // for PlaySound()
#include <time.h>
#include <mmsystem.h>
using namespace std;
int main(int argc, char* argv[])
{
FMOD::System *system;
FMOD::Sound *sound1, *sound2, *sound3;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
unsigned int version;
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
result = system->getVersion(&version);
result = system->init(32, FMOD_INIT_NORMAL, 0);
result = system->createSound("../media/drumloop.wav", FMOD_HARDWARE, 0, &sound1);
result = sound1->setMode(FMOD_LOOP_OFF); /* drumloop.wav has embedded loop points which automatically makes looping turn on, */
/* so turn it off here. We could have also just put FMOD_LOOP_OFF in the above CreateSound call. */
// Code continues into other bits that work...
I am using the latest version of FMOD and am using the Code::Blocks IDE (ver 10.05), with the GNU GCC compiler. The project is of type "Console application". The fmodex.dll file is in the folder of my project. I am using windows XP 32 bit SP3.
I have linked to the libfmodex.a
library and have tried linking to the other libraries it has there as well, but this does not solve the problem.
My question is, therefore, what do I need to do to stop these errors occurring? As when I encountered similar "Undefined reference to x" errors before using other libraries. I had just forgotten to link to them in Code::Blocks and as soon as I did, they would work.
Do say if you need more information regarding the code etc.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…