0

Although I include the header file of a class in my implementation like:

#include<Utility.h>

I still get fatal error: Utility.h: No such file or directory

Is there any idea why? Utility.h and Utility.cpp in my current project folder

Avb Avb
  • 545
  • 2
  • 13
  • 25
  • Is that header in your system headers directory? – chris Aug 22 '13 at 11:31
  • 4
    Is it a header that you wrote? Try `"Utility.h"` – jrok Aug 22 '13 at 11:31
  • Actually why doesn't it accept <> case instead of "" case. – Avb Avb Aug 22 '13 at 11:33
  • 3
    for <> vs "", check this question: http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename – codeling Aug 22 '13 at 11:34
  • Does your compiler looks in the directory where the header is? – Thanushan Aug 22 '13 at 11:35
  • 1
    If you tell your compiler to look in your current directly, such as with `-I .` or `/I .` (depending on your compiler), then it will add the current directory to the `<>` search list. – mah Aug 22 '13 at 11:36
  • @AvbAvb You people don't read beginner C++ tutorials, do you. –  Aug 22 '13 at 11:36
  • Did you want the standard C++ header 'utility' which has std::pair and the like? In which case you should `#include ` without the .h EDIT: I just reread the question and clearly you didn't... – Mike Vine Aug 22 '13 at 11:38
  • Add the header file path to your compile command using -I – bikram990 Aug 22 '13 at 11:40

2 Answers2

0
#include "Utility.h"

This is the way to include a .h file that you wrote and is in your project.

James Kanze
  • 150,581
  • 18
  • 184
  • 329
Emanuela
  • 86
  • 4
0
#include <file>
This variant is used for system header files. It searches for a file named file in a standard list of system directories. 

#include "file"
This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>. 
iampranabroy
  • 1,716
  • 1
  • 15
  • 11