Author Topic: Include file not found  (Read 22532 times)

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Include file not found
« on: July 11, 2014, 10:44:36 pm »
This problem comes from typing in a program contained within a text.  I get this error message:
<<
/home/xxxxx/Documents/Code Blocks Prj/Airline_Ticket_Test/main.cpp|5|fatal error: Headers.AirlineTicket.h: No such file or directory|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|
<<
AirlineTicket.h is located within the header/include  folder of my project.  Anyone know why it isn't being seen?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Include file not found
« Reply #1 on: July 11, 2014, 10:54:00 pm »
Probably because you've not told the compiler which folder is your include folder.  ::)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Include file not found
« Reply #2 on: July 11, 2014, 11:04:34 pm »
Probably because you've not told the compiler which folder is your include folder.  ::)

Ok, I'll bite.  So the compiler doesn't look for header files automatically in the header folder within the project?  If not, does this have to be set for each project, or is there a setting (which I haven't found yet)?  Thanks for the help.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Include file not found
« Reply #3 on: July 11, 2014, 11:18:51 pm »
Yes, it doens't. Project -> Build options -> Target /project -> Search directory -> Compiler
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Include file not found
« Reply #4 on: July 14, 2014, 01:12:19 am »
I've seen a bunch of posts from people new to CodeBlocks with this problem.  I solved it by going to settings->compiler->search directories tab.  Then just press the "new" button.  In the box that comes up is a button the allows you to see the project directory and just click the "include" directory under your project.   The compiler will now look in your project include directory for header files.  It doesn't seem intuitive that codeblocks would incorporate an include folder in the project directory and NOT search it for project header files, but it is what it is.   ???

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Include file not found
« Reply #5 on: July 14, 2014, 02:04:04 am »
How have you made C::B to incorporate include in your sources?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Include file not found
« Reply #6 on: July 14, 2014, 02:07:23 am »
How have you made C::B to incorporate include in your sources?

I apologize, but I don't understand your question.

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Include file not found
« Reply #7 on: July 14, 2014, 02:27:49 am »
Were you asking if a scope resolution operator works using my instructions?  Yes it does.  So I can refer to a definition in a header file using :: as long as I include the header file. 

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Include file not found
« Reply #8 on: July 14, 2014, 02:42:52 am »
Nope. I'm asking how have you added the file in <project_root>/include?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Include file not found
« Reply #9 on: July 14, 2014, 06:01:57 am »
Nope. I'm asking how have you added the file in <project_root>/include?

Ok, when I want to make a header file for a project, I do file->new->class and codeblocks automatically creates /headers/include in the project and creates the header template file in the include folder.  This folder is within the project.  Compiling at that point gives the error that the header can't be found.  Using the method I stated above, causes the compiler to search that folder for header files.  

But, now that I'm thinking about it, my method works, but is not correct.  I think it makes this project header folder the global header folder for all projects.  The proper way (which makes the project header folder searchable  by only this project) would be the way I think you spoke of earlier.  Project->Build Options->Search Directories tab.  On the left you will see the project name, debug and release.  Click the project name.  Then just press the "new" button.  In the box that comes up is a button the allows you to see the project directory and just click the "include" directory under your project.  

« Last Edit: July 14, 2014, 06:03:52 am by bangorme »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Include file not found
« Reply #10 on: July 14, 2014, 06:36:06 am »
Which version of C::B do you use ?
The class-wizard has an option to add the paths to the project, but I do not rememeber if it was added before or after the last release (13.12).

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Include file not found
« Reply #11 on: July 14, 2014, 04:57:12 pm »
I'm learning all kinds of stuff here, like C::B is the abbreviation for CodeBlocks.   I was using 12.11.  I found the nightly builds repository and am now running the lastest build.  I'll test it today and see if the problem is fixed.


Jenny178

  • Guest
Re: Include file not found
« Reply #12 on: July 24, 2014, 10:17:06 pm »
Nope. I'm asking how have you added the file in <project_root>/include?

Ok, when I want to make a header file for a project, I do file->new->class and codeblocks automatically creates /headers/include in the project and creates the header template file in the include folder.  This folder is within the project.  Compiling at that point gives the error that the header can't be found.  Using the method I stated above, causes the compiler to search that folder for header files.  

But, now that I'm thinking about it, my method works, but is not correct. Although it does work, you don't want to use it. I think it makes this project header folder the global header folder for all projects.  The proper way (which makes the project header folder searchable  by only this project) would be the way I think you spoke of earlier.  Project->Build Options->Search Directories tab.  On the left you will see the project name, debug and release.  Click the project name.  Then just press the "new" button.  In the box that comes up is a button the allows you to see the project directory and just click the "include" directory under your project.  



Hi
I am trying to go to project > build options but I don't have such menu.
« Last Edit: August 10, 2014, 02:46:55 am by Jenny178 »

Offline pirx67

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: Include file not found
« Reply #13 on: July 26, 2014, 12:28:51 am »
Are you sure you have created a project? How it is done is explained http://wiki.codeblocks.org/index.php?title=Creating_a_new_project.

If you have a project and it is opened / active in the menu "Project" should be a selectable sub-menu "Build options ...".
You can even right click the project name in the project manager tab and select "Build options ..." from the
popup menu. At least in current C::B releases.

Please supply the C::B version and operating system and its version to narrow the possible range of guessing.

Thanks,
    pirx67

Offline bangorme

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: Include file not found
« Reply #14 on: October 05, 2014, 03:59:56 am »
Well, I'm just getting back into C++ and having the exact same problems, even using the fix I posted earlier:

This is cut and pasted from  the book "Professional C++"

// SpreadsheetCell.h
class SpreadsheetCell
{
 public:
  void setValue(double inValue);
  double getValue() const;

 protected:
  double mValue;
};

// SpreadsheetCell.cpp
#include "SpreadsheetCell.h"

void SpreadsheetCell::setValue(double inValue)
{
  mValue = inValue;
}

double SpreadsheetCell::getValue() const
{
  return mValue;
}

#include "SpreadsheetCell.h"
#include <iostream>
using namespace std;

int main()
{
  SpreadsheetCell cell1;
  cell1.setValue(5.3);
  cout << cell1.getValue() << endl;

  return 0;
}

When I compile, I get the following errors:

||=== Build: Debug in SpreadsheetCellNumOnly (compiler: GNU GCC Compiler) ===|
/home/xxxx/Documents/Code Blocks Prj/SpreadsheetCellNumOnly/src/SpreadsheetCell.cpp|4|error: no ‘void SpreadsheetCell::setValue(double)’ member function declared in class ‘SpreadsheetCell’|
/home/xxxx/Documents/Code Blocks Prj/SpreadsheetCellNumOnly/src/SpreadsheetCell.cpp|9|error: no ‘double SpreadsheetCell::getValue() const’ member function declared in class ‘SpreadsheetCell’|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


Once again, it appears that Codeblocks isn't including Spreadsheet.h while compiling, even though I manually went in (as I posted previously) included the "include" directory in the project search path.  In fact, when I type in the code, Codeblocks correctly pops up the  Spreadsheet class methods correctly???????  Anyone have with an idea as to what's going on?

Thanks.