I am trying to use SDL2_mixer for sound but I get these errors
undefined reference to `Mix_OpenAudio'
undefined reference to `Mix_LoadWAV_RW'
undefined reference to `Mix_PlayChannelTimed'
According to Lazy Foo's tutorials undefined references mean that I have something wrong in my linker settings how every I believe I have it right. It goes as follows:
-lmingw32 -lSDL2main -lSDL2 -lSDL2_mixer -lSOIL -lOpenGL32
Additionally the search directories for the header and lib files are correct (I have triple checked) and the .dll is in the same directory as the executable. The code files also have the corresponding #include directories. There are not any more things I can think to try so any help is appreciated
I think you've the SDL mixer runtime binaries alone extracted into a directory. However, for compiling and linking you need the development libraries which has the stub library
libSDL2_mixer.dll.afile necessary for linking.In the SDL_mixer page, you've two sections: Runtime Binaries and Development Libraries. In the second section, download SDL2_mixer-devel-2.0.0-mingw.tar.gz (MinGW 32/64-bit). Extract it to a directory and add the (
/lib) directory path to C::B and pass-lSDL2_mixerand it should link just fine.When you run the executable, make sure
SDL2_mixer.dll(from the\bindirectory of the download) is present in the same directory for runtime dynamic linking to work.