linker - C++ Library Linking FMOD -
i trying write small program using fmod audio libraries having trouble understanding how link them.
i have small program looks follows
#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 instance of game engine } but when attempt compile using
g++ -l/home/me/fmod_test/api/lowlevel/lib/x86_64 -lfmod -lfmodl test.cpp -o test i error this
in function `fmod::system_create(fmod::system**)': test.cpp:(.text._zn4fmod13system_createeppns_6systeme[_zn4fmod13system_createeppns_6systeme]+0x14): undefined reference `fmod_system_create' i have included screenshots show these libraries , headers exist in system

interestingly enough, if comment out system_create call fmod::system , sound initializations still work fine.
am linking incorrectly, cant figure out why wouldnt working (and yes on x86_64 architecture per output of uname -a)
g++ -l/home/me/fmod_test/api/lowlevel/lib/x86_64 -lfmod -lfmodl test.cpp -o test
this command line backwards. explained in this answer, libraries must follow sources , object files on command line (the answer says order doesn't matter shared libraries, part of answer wrong (for @ least linkers)). try:
g++ -l/home/me/fmod_test/api/lowlevel/lib/x86_64 test.cpp -o test -lfmod -lfmodl
Comments
Post a Comment