SDL Play sound file - SDL/SDL_mixer.h [not found]

this is the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "stdlib.h"
#include "SDL/SDL_mixer.h>

int main(int argc, char *argv[])
{
        SDL_Surface *screen;
        Mix_Chunk *sound = NULL;
        int channel;
        int audio_rate = 22050;
        Uint16 audio_format = AUDIO_S16SYS;
        int audio_channels = 2;
        int audio_buffers = 4096;
        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
                printf("Unable to initialize SDL: %s\n", SDL_GetError());
                return 1;
        }
        if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) {
                printf("Unable to initialize audio: %s\n", Mix_GetError());
                exit(1);
        }
        sound = Mix_LoadWAV("sound.wav");
        if(sound == NULL) {
                printf("Unable to load WAV file: %s\n", Mix_GetError());
        }
        screen = SDL_SetVideoMode(320, 240, 0, SDL_ANYFORMAT);
        if (screen == NULL) {
                printf("Unable to set video mode: %s\n", SDL_GetError());
                return 1;
        }
        channel = Mix_PlayChannel(-1, sound, 0);
        if(channel == -1) {
                printf("Unable to play WAV file: %s\n", Mix_GetError());
        }
        while(Mix_Playing(channel) != 0);
        Mix_FreeChunk(sound);
        Mix_CloseAudio();
        SDL_Quit();
        return 0;
}

but I get mixer.h not found error.
Any possible reasons for this? I installed the latest version (1.2) from the official site today...
At first, I guess it should be "SDL/SDL_mixer.h" instead of "SDL/SDL_mixer.h>. Then you should check if the file is present in one of the Include search paths ( /usr/include/ by default). Maybe it's installed to /usr/local/include or something, then you should run gcc/g++ (I expect you to use gcc for now) with -I/usr/local/include .
Last edited on
Topic archived. No new replies allowed.