C ++:对'FMOD :: X'的未定义引用 [英] C++:Undefined reference to 'FMOD:: X'

查看:1130
本文介绍了C ++:对'FMOD :: X'的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看各种声音API库后,我决定暂时使用FMOD。

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:

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(ver 10.05),与GNU GCC编译器。项目类型为控制台应用程序。 fmodex.dll文件在我的项目的文件夹中。我使用的是windows XP 32位SP3。

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.

我已链接到 libfmodex.a 对于其他库,它也有在那里,但这不解决问题。

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.

我的问题是,因此,我需要做什么,以阻止这些错误发生?当我在使用其他库之前遇到类似的未定义的引用x错误。我刚刚忘记在Code :: Blocks中链接到他们,一旦我这样做,他们就可以工作了。

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.

推荐答案

当使用FMOD与Code :: Blocks时,您需要使用C API,而不是C ++ API。 FMOD是用Visual Studio构建的,因此C ++符号使用VC管理方案。在FMOD for Windows入门文档中提供了一条注释。

When using FMOD with Code::Blocks you need to use the C API, not the C++ API. FMOD is built with Visual Studio, therefore the C++ symbols use the VC mangling scheme. There is a note in the "Getting Started with FMOD for Windows" document that mentions this.

http://en.wikipedia.org/wiki/Name_mangling#How_different_compilers_mangle_the_same_functions

这篇关于C ++:对'FMOD :: X'的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆