Author Topic: Cannot include user's custom header file.  (Read 15025 times)

Offline 71GA

  • Single posting newcomer
  • *
  • Posts: 5
Cannot include user's custom header file.
« on: December 19, 2010, 02:03:33 pm »
Hello!

I have a problem with a header file named "playpen.h". I have written a program that needs this header file and here it is:
Code
#include <iostream>
#include "playpen.h"

int main()
{
    fgw:: playpen blank;
    std::cout << "Please press ENTER key";
    std::cin.get();
}

When i try to compile i allways get error saying: "playpen.h: No such file or directory ".
So i choose "projects/add files" and find playpen.h on my hard drive. After doing this
i can see the "headers" folder in my tree structure, but when trying to compile i still get
same error saying "playpen.h: No such file or directory ".


Anyone knows how I can solve this problem? TY
« Last Edit: December 19, 2010, 02:07:25 pm by 71GA »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Cannot include user's custom header file.
« Reply #1 on: December 19, 2010, 02:10:17 pm »
Anyone knows how I can solve this problem? TY
This message comes from the compiler, not the IDE.

The compiler tells you that it cannot find the file - this has nothing to do with whether you see this file in the IDE. So - in your project options, setup the compiler's include directory as needed. This will pass the path to your header file(s) to the compiler's command line. If needed, do the same with the linker so that the linker can find the library/libraries you need to link against.

BTW: Next time please search the forums before asking. This has been answered a million times.

In addition: This is also a quite basic question. If you learn developing applications in C/C++ I recommend you really try the command line first (not using any IDE) to learn the basics about how a compiler/linker works. This will help you a lot in setting up your projects using a(ny) IDE.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline 71GA

  • Single posting newcomer
  • *
  • Posts: 5
Re: Cannot include user's custom header file.
« Reply #2 on: December 19, 2010, 06:31:59 pm »
In addition: This is also a quite basic question. If you learn developing applications in C/C++ I recommend you really try the command line first (not using any IDE) to learn the basics about how a compiler/linker works. This will help you a lot in setting up your projects using a(ny) IDE.

Ty for the anwser (which worked) and advice on using terminal. Any advices where can i get good tutorial on Terminal commands (i am a Linux user)?

datahogg

  • Guest
Re: Cannot include user's custom header file.
« Reply #3 on: May 12, 2011, 02:56:18 pm »
Since this is such a common question. It might be good to give this a special place in the FAQ's.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Cannot include user's custom header file.
« Reply #4 on: May 12, 2011, 04:02:25 pm »
Isn't this http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F enough ?
The FAQ is in the Wiki, so feel free to update/improve it.
But keep in mind that most people ask the question, before doing any research.
(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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org