1

I'm learning SDL right now, and I want to play an MP3 file with SDL_mixer, so I installed it, but when I compile my program I get "undefined reference" errors for every SDL mixer function I use.

Here is my compile command:

g++ Player.cpp -o Player -L/opt/lib -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -lSDL `pkg-config gtkmm-3.0 --cflags --libs`

If I add -lSDL_mixe to this, it reports that it cannot find it.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
tagelicht
  • 467
  • 3
  • 14
  • 1
    You'd say `-lSDL_mixer`? – BiagioF Aug 21 '16 at 14:08
  • 1
    Yes that is what I meant^^ meanwhile, I figured it out, the problem was I was using -lSDL_mixer instead of -lSDL2_mixer. My Command now looks like this: g++ Player.cpp -o Player -L/opt/lib `sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer `pkg-config gtkmm-3.0 --cflags --libs` – tagelicht Aug 21 '16 at 14:49
  • *it reports that it cannot find it* - can you? Is there a `libSDL_mixer.so` or `libSDL_mixer.a` file in your library search paths? – keltar Aug 21 '16 at 18:45
  • Fixed some grammar and capitalization; removed `code` formatting from things that are *not* code or command-line text. – Paul Roub Aug 24 '16 at 23:36

0 Answers0