【发布时间】:2015-05-31 05:05:44
【问题描述】:
我目前正在尝试使用 FMOD 音频库编写一个小程序,但无法理解如何链接它们。
我有一个小程序,如下所示
#include "/home/me/fmod_test/api/lowlevel/inc/fmod.h"
#include "/home/me/fmod_test/api/lowlevel/inc/fmod.hpp"
#include "/home/me/fmod_test/api/lowlevel/inc/fmod_errors.h"
#include <iostream>
using namespace std;
int main()
{
FMOD::System *system;
FMOD::Sound *sound1;
FMOD::System_Create(&system); // create an instance of the game engine
}
但是当我尝试使用编译时
g++ -L/home/me/fmod_test/api/lowlevel/lib/x86_64 -lfmod -lfmodL test.cpp -o test
我收到这样的错误
In function `FMOD::System_Create(FMOD::System**)':
test.cpp:(.text._ZN4FMOD13System_CreateEPPNS_6SystemE[_ZN4FMOD13System_CreateEPPNS_6SystemE]+0x14): undefined reference to `FMOD_System_Create'
我已包含屏幕截图以显示这些库和标头确实存在于我的系统中
有趣的是,如果我注释掉 System_Create 调用,FMOD::System 和声音初始化仍然可以正常工作。
我是不是链接不正确,我不知道为什么这不起作用(是的,根据 uname -a 的输出,我在 x86_64 架构上)
【问题讨论】:
-
我认为你缺少 libfmodex.so
-
在最新版本的 FMOD 中似乎没有 libfmodex.so 库,旧版本似乎有这个库,我尝试使用
g++ -I/home/me/fmod_test/fmodex/inc/ -L/home/me/fmod_test/fmodex/lib/ -lfmodex64 -lfmodexL64 test.cpp -o test编译旧版本但仍然有同样的错误
标签: c++ linker shared-libraries fmod