Recommended Posts

Hey everyone. I am having trouble with just playing a sound in FMOD. Here is the Situation:
-I am using C++,(DevC++)
-I put all the includes in the include folder(hmod.hpp)
-I put the DLL's in the DLL folder(I dont understand what a DLL is but i figured it couldn't hurt?????
-I linked the appropriate library for DevC++(libfmodex.a)
-I included the appropriate header file for DevC++(hmod.hpp)
I ran the program after all the includes,libraries, and header files were in place-with no FMOD code in my app-and it worked fine.
Then I Added this Code after my windows main event loop(the one that dispatches messages, a while loop):

When I Try to run it it comes up with three errors that look like this:
1:-[Linker error] undefined reference to `_ZN4FMOD6System4initEijPv@16'
2:-[Linker error] undefined reference to `_ZN4FMOD6System11createSoundEPKcjP22FMOD_CREATESOUNDEXINFOPPNS_5SoundE@20'
3:- [Linker error] undefined reference to `_ZN4FMOD6System9playSoundE17FMOD_CHANNELINDEXPNS_5SoundEbPPNS_7ChannelE@20'
Do I have to do something with the .DLL files? Any and all help would be appreciated. If you need me to elaborate on anything ask, and don't afraid to be blunt. ;)
[Edited by - CG_KNOWLEDGE on January 5, 2006 4:31:13 AM]

Share this post

Link to post

Share on other sites

Hi,The errors you get are the linker complaining about not finding the object code referenced by your program.

When linking your library into DevCpp, you just have to write -lfmodex in Project Options -> Parameters -> Linker. DevCPP will know it is libfmodex.a. Be sure to have put the library in DevCPP lib directory.

There are three places where you can put fmodex.dll:- in the System32 directory of Windows (default directory where windows search for a DLL).- in the DLL directory of DevCpp.- in the directory of your compiled exe (windows searches first here - if it does not find the DLL, it will look then into system32 - if still not found it will look into DevCPP DLL directory).

I personally prefer to have the Fmod API integrated in the directories of DevCPP when developping. I find it cleaner.

Now when looking at your program, I advise you:- to include fmod_errors.h as it will help interpreting fmod error codes.

- to compare with the effects code example (you will see that playsound does not take an ending 0 but a pointer to a channel object).

- to separate fmod initiation from fmod update: they should not be in the event loop. Use an initiation function called once (holds the calls to system creation, initiation and call to playsound). In the event loop, just call system::update. Create a close function to release all resources (sound::release, system::close, system::release). Pointers to system, channel and sound objects are globals.