Code::Blocks Forums

User forums => Help => Topic started by: bangorme on July 11, 2014, 10:44:36 pm

Title: Include file not found
Post by: bangorme 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?
Title: Re: Include file not found
Post by: oBFusCATed on July 11, 2014, 10:54:00 pm
Probably because you've not told the compiler which folder is your include folder.  ::)
Title: Re: Include file not found
Post by: bangorme 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.
Title: Re: Include file not found
Post by: oBFusCATed on July 11, 2014, 11:18:51 pm
Yes, it doens't. Project -> Build options -> Target /project -> Search directory -> Compiler
Title: Re: Include file not found
Post by: bangorme 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.   ???
Title: Re: Include file not found
Post by: oBFusCATed on July 14, 2014, 02:04:04 am
How have you made C::B to incorporate include in your sources?
Title: Re: Include file not found
Post by: bangorme 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.
Title: Re: Include file not found
Post by: bangorme 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. 
Title: Re: Include file not found
Post by: oBFusCATed on July 14, 2014, 02:42:52 am
Nope. I'm asking how have you added the file in <project_root>/include?
Title: Re: Include file not found
Post by: bangorme 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.  

Title: Re: Include file not found
Post by: Jenna 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).
Title: Re: Include file not found
Post by: bangorme 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.

Title: Re: Include file not found
Post by: Jenny178 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 (http://www.dogbitelawyer.us) 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.
Title: Re: Include file not found
Post by: pirx67 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 (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
Title: Re: Include file not found
Post by: bangorme 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.


Title: Re: Include file not found
Post by: bangorme on October 05, 2014, 04:18:03 am
BTW, I'm using build 9916
Title: Re: Include file not found
Post by: stahta01 on October 05, 2014, 08:23:18 pm
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Title: Re: Include file not found
Post by: scarphin on October 05, 2014, 09:19:59 pm
Does it work if you use:
Code
#include <SpreadsheetCell.h>
instead of:
Code
#include "SpreadsheetCell.h"
Title: Re: Include file not found
Post by: bangorme on October 06, 2014, 02:02:47 am
Thank you to those that tried to help.  I spent two hours trying to chase down the problem.  Then just deleted the whole project directory.  Re cut and pasted the same code as I did before (from the book code file), and it worked.  I've got no idea what the problem was.  They only thing I noticed this time is that CodeBlocks created a "Headers" directory and not an "include" directory.