Jump to content
Tuts 4 You

[C++] help using uFMOD in Code::Blocks


ViL

Recommended Posts

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

    /* 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

https://pastebin.com/raw/fQDRwAVP

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

||=== 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

Link to comment

@evlncrn8 i am including the ufmod.h file that appears in the Example/C/WINMM/src folder of ufmodlib; i looked inside of it and says it is defining some uFMOD_Playsong

HWAVEOUT* __stdcall uFMOD_PlaySong(void*, void*, int);
#define uFMOD_StopSong() uFMOD_PlaySong(0, 0, 0)

i can't exactly tell what is wrong

@atom0s the static lib version seems to be these; BUT they come without header files, the ufmod.lib one is from ufmodlib\dll\implibs and the vb_winmm.lib i assume it is for visual basic on ufmodlib\lib; i am not really sure if i get what do you mean by static lib version; i downloaded uFMOD from here: https://sourceforge.net/projects/ufmod/files/uFMOD library for Win32/1.25.2/ufmod-1.25.2a-win32.7z/download?use_mirror=razaoinfo&r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fufmod%2Ffiles%2FuFMOD%20library%20for%20Win32%2F1.25.2%2Fufmod-1.25.2a-win32.7z%2Fdownload%3Fuse_mirror%3Drazaoinfo%26r%3D%26use_mirror%3Drazaoinfo&use_mirror=razaoinfo

sourceforce says it may contain malware BUT i think it is a false positive since it seems there where everyone links uFMOD to

could it be that i can't compile it on Code::Blocks? :c thanks in advance! :D

vb_winmm.lib

ufmod.lib

Edited by vilxdryad
Link to comment

Hi

 

Go to your project in project manager, right click and "Build Option" 

Tab linker settings in field link Libraries add winmm and ufmod lib

And copy ufmod.lib in your project folder.

 

Regards,

Edited by ragdog
  • Like 1
Link to comment

@ragdog now i figured out! :D  though when linking the winmm.lib and ufmod.lib ufmod.lib specificaly, it ask me for the ufmod.dll to run to build which i don't want because my approach is to have everything in one exe, like most intro does ;-;

and regardless, i put the ufmod.dll and it runs! BUT freezes on start forever; so i can't hear if even the playback works

though it compiled without error nor warnings at least :D

is there a solution that doesn't force me to bundle the ufmod.dll to the exe? :) btw thanks for your response! x3

EDIT: now i tried including the ufmod.obj that came in the ufmodlib's Example/C/WINMM/src folder instead of the ufmod.lib and it throws me these errors when compling

||=== Build: Release in test (compiler: GNU GCC Compiler) ===|
D:\ogl\test\ufmod.obj|| undefined reference to `_imp__waveOutOpen@24'|
D:\ogl\test\ufmod.obj|| undefined reference to `_imp__waveOutPrepareHeader@12'|
D:\ogl\test\ufmod.obj|| undefined reference to `_imp__waveOutWrite@12'|
D:\ogl\test\ufmod.obj|| undefined reference to `_imp__waveOutReset@4'|
D:\ogl\test\ufmod.obj|| undefined reference to `_imp__waveOutUnprepareHeader@12'|
D:\ogl\test\ufmod.obj|| undefined reference to `_imp__waveOutClose@4'|
D:\ogl\test\ufmod.obj|| undefined reference to `_imp__waveOutGetPosition@12'|
||error: ld returned 1 exit status|
||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 22 second(s)) ===|

BUT when also including the vb_winmm.lib it compiles fine and run! =' D BUT crashes immediately after showing the windows;

Process terminated with status -1073741819 (0 minute(s), 57 second(s))

could it be that i can't compile ufmodlib on Code::Blocks after all? :c

Edited by vilxdryad
Link to comment

Hi

 

Quote

is there a solution that doesn't force me to bundle the ufmod.dll to the exe?

Yes use the  static library you use a lib for dynamic (dll).

As i remember this archiv from ufmod contain a library for static linking. (without dll).
Masm32 is similar to cpp with linking you can try to use the "Examples\Masm32\WinMM\ufmod.lib"
or build a new with "\Examples\C\WinMM\" Visual studio project files
 
regards,
  • Like 1
Link to comment

Found the solution! \o/ thanks so much guys! :D i 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 :) that ufmod version comes along this 7z too = p

the ufmod.h file was took from its \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+

IMPORTANT

I linked both WinnMM.Lib and ufmod.h to the project using my own full paths! 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 for it to work! :D/

wish you a nice time, and once more; thanks you a lot guys for your help! x3

btw; since i changed my name from vilxdryad to ViLXDRYAD, i can't edit the posts i made with my previous name anymore lol rip, so if a mod pleases to append [SOLVED] to the thread title that could be nice :)

uFMOD_example4CodeBlocks.7z

Edited by ViLXDRYAD
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...