SDL_Mixer Mix_LoadWAV can not find RIFF or WAVE identifiers

I have asked this before since december but was ignored everywhere so I am trying to ask this one last time.

I am trying to load an audio file (as an Mix_Chunk) but I am getting the following error message:

"Could not find RIFF or WAVE identifiers (not a Waveform file)"

I tried all export settings in Audacity that I know of, what could I be doing wrong here?

I did everything correctly, I even checked using an hex editor and the identifiers are there. File in an hex editor

This issue happens with any file format I try. FOpen was able to read the identifier bytes perfectly too, what could the issue be?

I am using gcc to compile on an Ubuntu machine. I used the package manager to install everything.

The code:

#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <string>
#include <iostream>
int main() {
    int Mixer = Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 );
    if(Mixer < 0)
    {
        std::cout << "Mixer wasn't initialized.";
        return 0;
    }
    if( SDL_Init( SDL_INIT_AUDIO ))
    {
        std::cout << "Sdl audio wasn't initialized.";
        return 0;
    }

    Mix_Chunk *mc = Mix_LoadWAV("YouGotMail.wav");
    
    if (!mc)
    {
        std::cout << std::string(std::string("Failed to load audio YouGotMail.wav.\n") + Mix_GetError()).c_str() << std::endl;
        return 0;
    }
    return 0;
}

Using ldd on the executable gives me this output:

linux-vdso.so.1 (0x00007ffe219be000)
        libSDL2-2.0.so.0 => /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (0x00007f569c0eb000)
        libSDL2_image-2.0.so.0 => /lib/x86_64-linux-gnu/libSDL2_image-2.0.so.0 (0x00007f569c0c8000)
        libSDL_mixer-1.2.so.0 => /lib/x86_64-linux-gnu/libSDL_mixer-1.2.so.0 (0x00007f569c073000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f569be91000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f569be76000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f569bc84000)
        libasound.so.2 => /lib/x86_64-linux-gnu/libasound.so.2 (0x00007f569bb87000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f569ba38000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f569ba32000)
        libpulse.so.0 => /lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f569b9dd000)
        libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f569b8a0000)
        libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f569b88b000)
        libXcursor.so.1 => /lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f569b87c000)
        libXinerama.so.1 => /lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f569b877000)
        libXi.so.6 => /lib/x86_64-linux-gnu/libXi.so.6 (0x00007f569b865000)
        libXrandr.so.2 => /lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f569b858000)
        libXss.so.1 => /lib/x86_64-linux-gnu/libXss.so.1 (0x00007f569b853000)
        libXxf86vm.so.1 => /lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f569b84c000)
        libwayland-egl.so.1 => /lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f569b845000)
        libwayland-client.so.0 => /lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f569b834000)
        libwayland-cursor.so.0 => /lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f569b829000)
        libxkbcommon.so.0 => /lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f569b7e7000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f569b7c4000)
        libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f569b78c000)
        libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f569b705000)
        libtiff.so.5 => /lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f569b684000)
        libwebp.so.6 => /lib/x86_64-linux-gnu/libwebp.so.6 (0x00007f569b61a000)
        libSDL-1.2.so.0 => /lib/x86_64-linux-gnu/libSDL-1.2.so.0 (0x00007f569b57e000)
        libmikmod.so.3 => /lib/x86_64-linux-gnu/libmikmod.so.3 (0x00007f569b33b000)
        libfluidsynth.so.2 => /lib/x86_64-linux-gnu/libfluidsynth.so.2 (0x00007f569b269000)
        libvorbisfile.so.3 => /lib/x86_64-linux-gnu/libvorbisfile.so.3 (0x00007f569b25c000)
        libFLAC.so.8 => /lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f569b21e000)
        libmad.so.0 => /lib/x86_64-linux-gnu/libmad.so.0 (0x00007f569b1fb000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f569c293000)
        libpulsecommon-13.99.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-13.99.so (0x00007f569b179000)
        libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f569b128000)
        libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f569b0fc000)
        libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f569aef2000)
        libXfixes.so.3 => /lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f569aeea000)
        libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007f569aede000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f569aec2000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f569ae17000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f569adee000)
        libjbig.so.0 => /lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f569abe0000)
        libpulse-simple.so.0 => /lib/x86_64-linux-gnu/libpulse-simple.so.0 (0x00007f569abd9000)
        libcaca.so.0 => /lib/x86_64-linux-gnu/libcaca.so.0 (0x00007f569ab0d000)
        libopenal.so.1 => /lib/x86_64-linux-gnu/libopenal.so.1 (0x00007f569aa25000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f569a8fa000)
        libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f569a8f4000)
        libjack.so.0 => /lib/x86_64-linux-gnu/libjack.so.0 (0x00007f569a8a8000)
        libsndfile.so.1 => /lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f569a82a000)
        libreadline.so.8 => /lib/x86_64-linux-gnu/libreadline.so.8 (0x00007f569a7da000)
        libinstpatch-1.0.so.2 => /lib/x86_64-linux-gnu/libinstpatch-1.0.so.2 (0x00007f569a71f000)
        libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f569a6bd000)
        libvorbis.so.0 => /lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f569a68f000)
        libogg.so.0 => /lib/x86_64-linux-gnu/libogg.so.0 (0x00007f569a682000)
        libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f569a5d3000)
        libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f569a5c7000)
        libasyncns.so.0 => /lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f569a3bf000)
        libapparmor.so.1 => /lib/x86_64-linux-gnu/libapparmor.so.1 (0x00007f569a3aa000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f569a39f000)
        libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f569a399000)
        libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f569a391000)
        libslang.so.2 => /lib/x86_64-linux-gnu/libslang.so.2 (0x00007f569a09a000)
        libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x00007f569a05e000)
        libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f569a02e000)
        libsndio.so.7.0 => /lib/x86_64-linux-gnu/libsndio.so.7.0 (0x00007f569a01d000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f5699faa000)
        libvorbisenc.so.2 => /lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f5699eff000)
        liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f5699edc000)
        libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f5699dbe000)
        libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f5699da1000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f5699d85000)
        libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f5699d6b000)
        libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f5699d46000)

1 answer

  • answered 2022-01-23 19:00 Lila

    The problem I was having was that I was linking the old sdl mixer which doesnt work with SDL2, adding lSDL2_mixer library to my make file fixed the error, thank you so much keltar and danadam for pointing this out.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum