SDL2 mixer error

When trying to load a wav-file to the mixer of SDL I get an error: undefined reference to `Mix_LoadWAV'. Also, Mix_OpenAudio is complaining that it has too many arguments. I have linked to SDL2.dll and SDL2_mixer.dll. Without the mixer functions, I am able to play a wav-file using SDL.

1
2
3
4
5
6
7
#include "SDL_mixer.h"

    Mix_Chunk *wave = NULL;
    SDL_Init(SDL_INIT_EVERYTHING);
    Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 512);
    wave = Mix_LoadWAV("MyTest1.wav");
    Mix_PlayChannel(1, wave, 0);


What am I doing wrong here in Eclipse?
Last edited on
> Also, Mix_OpenAudio is complaining that it has too many arguments
It seems the API changed.

https://wiki.libsdl.org/SDL2_mixer/Mix_OpenAudio
vs
https://wiki.libsdl.org/SDL3_mixer/Mix_OpenAudio

Not sure why you would even be getting linker errors when you have a compile error to deal with.
As pointed out before, "error: undefined reference to XYZ" is a linker error and usually indicates that you are missing a required library:
https://cplusplus.com/forum/beginner/285624/

In this particular case, try adding -lSDL2 and maybe -lSDL2_mixer to your linker options. If on Windows/MSVC, try linking SDL2.lib.
Last edited on
Topic archived. No new replies allowed.