Code::Blocks Forums

User forums => Help => Topic started by: Ertzel on February 16, 2011, 03:35:35 am

Title: #include File Error
Post by: Ertzel on February 16, 2011, 03:35:35 am
So im trying to include a file into my current project. I have the project all setup with both files in it, then when I try to include the one page with the other im getting the error

"C:\Users\owner\Desktop\Game Development\C++\Tests\Programs\Visual\Button\Maze\main.cpp|4|Data.h: No such file or directory"

my include looks like this...

#include <Data.h>

Data.h is in the same folder as main.cpp and the same folder as the whole project is (the Maze folder). If I change the include to look like this...

#include <C:\Users\owner\Desktop\Game Development\C++\Tests\Programs\Visual\Button\Maze\Data.h>

Then it works fine with no errors and loads the data from Data.h. My question is, why do I have to put the whole path towards Data.h instead of just <Data.h>, Its really annoying to have to write out the whole patch for each file I include in the project.

(This is my first day using CodeBlocks so sorry if this is a retarded question)
Title: Re: #include File Error
Post by: MortenMacFly on February 16, 2011, 08:25:37 am
Setup a project and adjust the include directories from the project settings. See the Code::Blocks manual for details.
http://www.codeblocks.org/docs/main_codeblocks_en.html
Title: Re: #include File Error
Post by: Jenna on February 16, 2011, 08:52:41 am
The problem you have is not C::B, it's the way the compiler searches for headers.
If you use "<" and ">" to include the header-file, it searches in the systems default directory and the explicitely set include-directories.

There are thre possible solutions:
Title: Re: #include File Error
Post by: Ertzel on February 16, 2011, 10:20:06 am
There are thre possible solutions:
  • use double-quotes to include the header instead of the angle-brackets

Thanks both of you, changing the < > to " " fixed it for me and now its working with just putting #include "Data.h"