The program can't locate the header files.

When I compile the program it can't locate the custom header files

Page 1 of 1

7 Replies - 2554 Views - Last Post: 13 September 2009 - 10:34 PM Rate Topic: -----

#1 Yami  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 13-September 09

The program can't locate the header files.

Posted 13 September 2009 - 01:41 PM

Hi, I tried searching and browsing through the tutorial, but I can't seem to find out what's wrong with the program.

For instance there is a DrawLine.h file, and the entire SDL library which we got in order to complete our first assignement

DrawLine looks like this:
#ifndef DRAWLINE_H_
#define DRAWLINE_H_

// Draw a line on the screen from x1,y1 to x2,y2 with a given pen color
void DrawLine(SDL_Surface *screen, int x1, int y1, int x2, int y2, unsigned int color);

#endif /*DRAWLINE_H_*/



And the code we were given to work on (so we wouldn't have to find out how to make a graph), was this:
#include <stdlib.h>
#include <assert.h>
#include <SDL.h>

int main(int argc, char *argv[]);
int _x1,_x2,_y1,_y2;

// Set pixel x,y on the screen
void SetPixel(SDL_Surface *screen, int x, int y, unsigned int color);
{
	unsigned int *bufp;

	// Set pixel
	bufp = (unsigned int*)screen->pixels + y*screen->pitch/4 + x;
	*bufp = color;	
 	
	// Force screen update
	SDL_UpdateRect(screen, x, y, 1, 1);
}

// Draw a line on the screen from x1,y1 to x2,y2
void DrawLine(SDL_Surface *screen, int x1, int y1, int x2, int y2, unsigned int color)
{
	
		// Complete this function
dx = x2 - x2;
dy = y2 - y1;

if(dx<0);
dx = -dx;
stepx = -1;
else  
	  stepx = 1;

if(dy<0);
dy = -dy;
stepy = -1;
else
stepy = 1; 

dx = 2*dx;
dy = 2*dy;

x = x1;
y = y2;

SetPixel (x,y);

H(dx>dy){
		 fraction=dy-(1/2)dx;
		 while(x!=x2){
					  if(fraction>=0){
									  y=y+stepy;
									  fraction=fraction-dx;
									  }
					  
					  x=x+stepx;
					  fraction=fraction+dy;
					  }
					  
					  SetPixel(x,y); 
		 }
else
fraction=dx-(1/2)dy;
while(y!=y2) {
			 if(fraction>=0);
			 x=x+stepx;
			 fraction = fraction - dy;
			 y=y+stepy;
			 fraction = fraction + dx;
			 
			 SetPixel(x,y);
			 }


}


int main(int argc, char **argv)
{
	int retval, done, x, y;
	SDL_Surface *screen;
	SDL_Event event;
	
	// Initialize SDL	
	retval = SDL_Init(SDL_INIT_VIDEO);
	if (retval == -1) {
		printf("Unable to initialize SDL\n");
		exit(1);	
	}
	
	//Create a 640x480x32 window
	screen = SDL_SetVideoMode(640, 480, 32, 0); 	
	if (screen == NULL) {
		printf("Unable to get video surface: %s\n", SDL_GetError());	
		exit(1);
	}

	// Example call. Remember to pass screen as first parameter.
	// The SDL_MapRGB function converts a RGB value to
	// a 32-bit value (each color is 8 bit)
	DrawLine(screen, 0, 0, 100, 200,);
		SDL_MapRGB(screen->format, 0xff, 0, 0));


	// Wait for ctrl-c from user
	done = 0;
	while (done == 0) {
		while (SDL_PollEvent(&event)) {
			switch (event.type) {
			case SDL_QUIT:
				done = 1;
				break;	
			}			
		}
	}	
	
	SDL_Quit();
}




With the function under //complete this function, being the suggested way to solve the task that was given.

This was the first assignement, and not mandatory. The mandatory one is to pinpoint 3 points, draw a line between them, colour in the middle so you get a coloured triangle, then make a teapot out of said triangles, but that's beside the point.

The error I'm getting is mainly stuff like "SDL.h: no such file or directory." "DrawLine.h: no such file or directory.

All the SDL headers are in the include file for the project, exept the DrawLine one which is in the same file as the drawline.c function.

I'm using Dev-C++ and the university is using Eclipse, dunno if this got anything to do with it.

I'm sorry if I just posted something that's been asked about tons of times already. But I couldn't find it. It's just so annoying that I can't even start on the assignement because I can't seem to get the tools we were given to work.

Thanks in advance. :)

Is This A Good Question/Topic? 0
  • +

Replies To: The program can't locate the header files.

#2 AntonWebsters  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 88
  • View blog
  • Posts: 428
  • Joined: 15-August 09

Re: The program can't locate the header files.

Posted 13 September 2009 - 01:49 PM

Try #include "SDL.h"...
Was This Post Helpful? 0
  • +
  • -

#3 KYA  Icon User is online

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: The program can't locate the header files.

Posted 13 September 2009 - 01:55 PM

since you're using <>, the compiler looks in its include directory. If it's in the local directory use double quotes " ".
Was This Post Helpful? 0
  • +
  • -

#4 Yami  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 13-September 09

Re: The program can't locate the header files.

Posted 13 September 2009 - 01:58 PM

Ah, sorry. I tried to change it to <> tags because the "" tags didn't work. Changed them back now and it's still giving the same error message.
Was This Post Helpful? 0
  • +
  • -

#5 KYA  Icon User is online

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: The program can't locate the header files.

Posted 13 September 2009 - 01:59 PM

Did you install SDL correctly? Do you have the external dependencies linked in your options menu?

This post has been edited by KYA: 13 September 2009 - 02:00 PM

Was This Post Helpful? 0
  • +
  • -

#6 Yami  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 13-September 09

Re: The program can't locate the header files.

Posted 13 September 2009 - 02:16 PM

Erm, I have no clue what you just said but I hope it was the solution... :P
Was This Post Helpful? 0
  • +
  • -

#7 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Re: The program can't locate the header files.

Posted 13 September 2009 - 04:43 PM

What compiler are you using?
Link the dependencies is going to linker options and adding the .lib of the libraries to it
Was This Post Helpful? 0
  • +
  • -

#8 Yami  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 13-September 09

Re: The program can't locate the header files.

Posted 13 September 2009 - 10:34 PM

I'm using Dev-C++, but I'm definatly open for suggestions.
And I can't find linker options... or options in general. Tried installing SDL through some package manager, but it didn't seem to work. Tried to add it to the library manually and that didn't work either.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1