when i try to compile this code i get

ERORR: unable to open include file sdl.h

#include "stdlib.h"
#include "SDL/SDL.h"
// *** IF USING XCODE ON MACOS X, YOU MAY NEED TO CHANGE THE FOLLOWING LINE TO:  #include "SDL_mixer/SDL_mixer.h"
#include "SDL/SDL_mixer.h"

//Function prototyping action!
void musicFinished();

int musicPlaying = 0;				//Is the music playing, or not?

int main(int argc, char *argv[])
{
	SDL_Surface *screen;			//Pointer to the main screen surface
	Mix_Music *music;			//Pointer to our music, in memory
	  
	int audio_rate = 22050;			//Frequency of audio playback
	Uint16 audio_format = AUDIO_S16SYS; 	//Format of the audio we're playing
	int audio_channels = 2;			//2 channels = stereo
	int audio_buffers = 4096;		//Size of the audio buffers in memory
	
	//Initialize BOTH SDL video and SDL audio
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) 
	{
		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 1;
	}
	
	//Initialize SDL_mixer with our chosen audio settings
	if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) 
	{
		printf("Unable to initialize audio: %s\n", Mix_GetError());
		return 1;
	}
	
	//Load our OGG file from disk
	music = Mix_LoadMUS("music.ogg");
	if(music == NULL) 
	{
		printf("Unable to load OGG file: %s\n", Mix_GetError());
		return 1;
	}
	
	//Set the video mode to anything, just need a window
	screen = SDL_SetVideoMode(320, 240, 0, SDL_ANYFORMAT);
	if (screen == NULL) 
	{
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return 1;
	}
	if(Mix_PlayMusic(music, 0) == -1) 
	{
		printf("Unable to play OGG file: %s\n", Mix_GetError());
		return 1;
	}
	musicPlaying = 1;
	Mix_HookMusicFinished(musicFinished);
	while(musicPlaying)
	{
		SDL_Delay(100);
	}
	Mix_HaltMusic();
	Mix_FreeMusic(music);
	Mix_CloseAudio();
	SDL_Quit();	
	return 0;
}

void musicFinished()
{	musicPlaying = 0;
}

Where can i get it.

Which Distro of Linux are u using, Accordingly you will need to install the SDL development package for that platform,
You seem to be working with the sound library of SDL, on Ubuntu the package that you need to install would be libsdl-sound1.2-dev

Which Distro of Linux are u using, Accordingly you will need to install the SDL development package for that platform,
You seem to be working with the sound library of SDL, on Ubuntu the package that you need to install would be libsdl-sound1.2-dev

I am using ubuntu hardy.

But i am trying to compiling this code with my windows[Borland c compliler]

in ubuntu when i tried with gcc i got the following

raj@raj-desktop:~$ gcc /home/raj/c/SDL_PlayMusic.c/tmp/cc7kWhSf.o: In function `main':
SDL_PlayMusic.c:(.text+0x34): undefined reference to `SDL_Init'
SDL_PlayMusic.c:(.text+0x3d): undefined reference to `SDL_GetError'
SDL_PlayMusic.c:(.text+0x7a): undefined reference to `Mix_OpenAudio'
SDL_PlayMusic.c:(.text+0x83): undefined reference to `SDL_GetError'
SDL_PlayMusic.c:(.text+0xab): undefined reference to `Mix_LoadMUS'
SDL_PlayMusic.c:(.text+0xb9): undefined reference to `SDL_GetError'
SDL_PlayMusic.c:(.text+0xf9): undefined reference to `SDL_SetVideoMode'
SDL_PlayMusic.c:(.text+0x107): undefined reference to `SDL_GetError'
SDL_PlayMusic.c:(.text+0x136): undefined reference to `Mix_PlayMusic'
SDL_PlayMusic.c:(.text+0x140): undefined reference to `SDL_GetError'
SDL_PlayMusic.c:(.text+0x16f): undefined reference to `Mix_HookMusicFinished'
SDL_PlayMusic.c:(.text+0x17d): undefined reference to `SDL_Delay'
SDL_PlayMusic.c:(.text+0x18b): undefined reference to `Mix_HaltMusic'
SDL_PlayMusic.c:(.text+0x196): undefined reference to `Mix_FreeMusic'
SDL_PlayMusic.c:(.text+0x19b): undefined reference to `Mix_CloseAudio'
SDL_PlayMusic.c:(.text+0x1a0): undefined reference to `SDL_Quit'
collect2: ld returned 1 exit status
raj@raj-desktop:~$

Any help please

In your Hardy just hit

sudo apt-get install libsdl-sound1.2-dev

in your terminal, and try compiling your code.
Also in case the problem does not get solved, hit the following command in your terminal

apt-cache search libsdl

This will give you a list of packages associated with SDL and their description,
However from your code I feel the libsdl-sound1.2-dev package should do the job, in case it doesn't you will have to go thru the package list in the output of the second command and install the one you feel is needed by ur program.

inti@administrator-desktop:~/Desktop$ gcc -o m m.c `sdl-config --cflags --libs` -lsdl_mixer
m.c:3:23: error: SDL_mixer.h: No such file or directory
m.c: In function ‘main’:
m.c:9: error: ‘Mix_Chunk’ undeclared (first use in this function)
m.c:9: error: (Each undeclared identifier is reported only once
m.c:9: error: for each function it appears in.)
m.c:9: error: ‘sound’ undeclared (first use in this function)
inti@administrator-desktop:~/Desktop$
I got this errors message while trying to run my code.
Could anyone help tell me why?

This article has been dead for over six months. Start a new discussion instead.