C++ C++;图书馆链接FMOD

C++ C++;图书馆链接FMOD,c++,linker,shared-libraries,fmod,C++,Linker,Shared Libraries,Fmod,我目前正在尝试使用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>

我目前正在尝试使用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
}
我犯了这样的错误

In function `FMOD::System_Create(FMOD::System**)':
test.cpp:(.text._ZN4FMOD13System_CreateEPPNS_6SystemE[_ZN4FMOD13System_CreateEPPNS_6SystemE]+0x14): undefined reference to `FMOD_System_Create'
我已经包括了屏幕截图,以显示这些库和标题确实存在于我的系统中

有趣的是,如果我注释掉系统创建调用FMOD::系统和声音初始化仍然可以正常工作

如果我链接不正确,我无法理解为什么这不起作用(是的,根据uname-a的输出,我使用的是x86_64体系结构)

g++-L/home/me/fmod_test/api/lowlevel/lib/x86_64-lfmod-lfmodL test.cpp-o test

此命令行是向后的。如中所述,库必须遵循命令行上的源文件和对象文件(答案是,顺序对共享库不重要,但答案的这一部分是错误的(至少对某些链接器而言))。尝试:


我认为您缺少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编译旧版本,但仍然有相同的错误
In function `FMOD::System_Create(FMOD::System**)':
test.cpp:(.text._ZN4FMOD13System_CreateEPPNS_6SystemE[_ZN4FMOD13System_CreateEPPNS_6SystemE]+0x14): undefined reference to `FMOD_System_Create'
g++ -L/home/me/fmod_test/api/lowlevel/lib/x86_64 test.cpp -o test -lfmod -lfmodL