Unable To Get SDL2_Mixer 2.0.2 To Init On Both Win 10 & Linux?


I updated to current SDL2, SDL2_Image, SDL2_Mixer, & SDL2_TTF today.
I can’t seem to get current SDL2_Mixer 2.0.2 to initialize on both Windows 10 and Manjaro Linux?

Below is relevant source code:

void Audio::SetupAudio(void)
strcpy(Mix_Init_Error, “SDL2_Mixer: OK”);


int initted = Mix_Init(flags);
if ( (initted&flags) != flags )
    printf("Mix_Init: Failed to init required ogg and mod support!\n");
    printf("Mix_Init: %s\n", Mix_GetError());

    strcpy(Mix_Init_Error, "SDL2_Mixer ERROR: ");
    strcat( Mix_Init_Error, Mix_GetError() );

    AudioWorking = false;

Getting an error on both Windows and Linux for whichever SDL2_Mixer init flag I use?
Either: “Mix_Init: OGG support not available” or “Mix_Init: MOD support not available”
(on both Windows 10 and Linux the entire source code builds with zero warnings and zero errors)

Any help would be appreciated, thanks!


Ok, I got audio working by changing it to:

if (initted&flags != flags) { … }

But I am getting an annoying build warning now:

E:\TC4T-WinLinux-Retail2\src\audio.cpp|84|warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]|

How do I fix the above warning?


if (initted&flags && !flags)

if (initted&flags != flags) { … }

Due to the operator precedence of &, this is the same as:

if (initted & (flags != flags)) { … }
if (initted & 0) { … }
if (0) { … }

I always use parens around the arguments to & to avoid this. That’s what the warning was talking about.

see: https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence