Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: ViLXDRYAD on January 08, 2018

Title: [C++] help using uFMOD in Code::Blocks (Solved, Example attached!)
Post by: ViLXDRYAD on January 08, 2018
Hii, there's been a lots of obstacles on my first intro making BUT most of them have been resolved either by trying hard or looking for threads on forums

BUT this time i can't find the answer anywhere, so i ask your help to solve this puzzle

on my main.c project (Code::Blocks always create it with .c when using the OpenGL Project template BUT i still use C++ on it) i have included this ufmod.h header:

https://pastebin.com/raw/UMuqxB6h (Note that it specifies Compiler: Visual C, Dev-C++ BUT i want to use Code::Blocks :c)

and have this function to play music
Code: [Select]
    /* music function */
      void play_xm(){
      uFMOD_PlaySong((char*)1, 0, XM_RESOURCE);

and of course, call it inside of the main() function with play_xm();

also i have included a main.rc resource file to the project with not much besides the xm song data i want to play is the one that comes in the jmp2pat.rc of the uFMOD examples, also i kept the example's comments on it for now


and when i run it, it pops the following error at building

Code: [Select]
||=== Build: Release in test (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.c|| undefined reference to `uFMOD_PlaySong@12|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 6 second(s)) ===|

though, if i comment the play_xm(); function on main() it compiles with no errors nor warnings

can someone help me please? thanks a lot in advance! :D
Title: Re: [C++] help using uFMOD in Code::Blocks
Post by: Rbz on January 08, 2018

You will need to include and link "ufmod.obj" and "winmm.lib" files for it to work.

I've never used code::blocks, but I think it should be easy for you to find the linker project page.

Usually you will find the file "ufmod.obj" on the same directory of "ufmod.h" which is:
Title: Re: [C++] help using uFMOD in Code::Blocks
Post by: ViLXDRYAD on January 09, 2018
Yoo, Rbz! :D thanks for your reply; i already found the solution and it turned out harder than i expected

had to use the WinMM.Lib that come in the Windows SDK for Windows 7 and .NET Framework 3.5 SP1 instead of the one bundled in the ufmod-1.25.2a-win32.7z for it to work! :D that ufmod version comes along this zip too = p

also used the ufmod.h from \Example\C\WinMM\src folder and the ufmod.lib frfom the \Example\Masm32\WinMM folder! :D just copied them to the project folder, linked them and it works like a charm! =' D so i uploaded a working project example of uFMODLib on Code::Blocks for everyone else that is struggling with this! +O+


I linked both WinnMM.Lib and ufmod.h to the project using my own full paths! you must delete them in the Project tab > Build options... > Linker Libraries and add them both once more from there BUT using you own paths to the library this time for it to work!

thanks for your help too, and if you ever are into C++ programming, i'd totally recommend you Code::Blocks IDE! x3 it is the best one i have used so far, any doubt anyone have about this example please reply here and i'll try to answer asap :) hope this helps! x3