環顧各種聲音API庫之後,我決定暫時使用FMOD。C++:對'FMOD :: X'的未定義引用
問題是,每當我試圖編譯的代碼示例之一,我得到了以下錯誤:我使用是這個
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::System::getVersion(unsigned int*)@8'|
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::System::init(int, unsigned int, void*)@16'|
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::System::createSound(char const*, unsigned int, FMOD_CREATESOUNDEXINFO*, FMOD::Sound**)@20'|
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::Sound::setMode(unsigned int)@8'|
的代碼示例:
#include <D:\Games\FMOD Programmers API Win32\api\inc\fmod.hpp>
#include <D:\Games\FMOD Programmers API Win32\api\inc\fmod_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...
我使用最新版本的FMOD,並使用Code :: Blocks IDE(版本10.05)和GNU GCC編譯器。該項目是「控制檯應用程序」類型。 fmodex.dll文件位於我的項目文件夾中。我正在使用Windows XP 32位SP3。
我已經聯繫到libfmodex.a
庫,並嘗試連接到它擁有那裏,以及其他圖書館,但這並不解決問題。
我的問題是,因此,我需要做什麼來制止這些錯誤發生的?就像我在使用其他庫之前遇到類似的「Undefined reference to x」錯誤一樣。我剛剛忘記了在Code :: Blocks中鏈接到它們,只要我這樣做,它們就會工作。
難道說,如果你需要有關代碼等
如果可能的話,我仍然需要更多幫助。 – James 2011-03-14 20:29:54
你如何調用鏈接器,例如makefile中的行。 – fizzer 2011-03-14 20:49:55
我不使用makefile(也許我應該,需要幫助,雖然)我使用項目構建選項..鏈接器設置,並通過該添加庫文件夾。 (這是與codeblocks) – James 2011-03-14 20:56:53