Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: 71GA on December 19, 2010, 02:03:33 pm

Title: Cannot include user's custom header file.
Post by: 71GA 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 ".
(http://www.shrani.si/f/2k/ry/2PYPHfQJ/error.png)

Anyone knows how I can solve this problem? TY
Title: Re: Cannot include user's custom header file.
Post by: MortenMacFly 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.
Title: Re: Cannot include user's custom header file.
Post by: 71GA 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)?
Title: Re: Cannot include user's custom header file.
Post by: datahogg 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.
Title: Re: Cannot include user's custom header file.
Post by: oBFusCATed 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.
Title: Re: Cannot include user's custom header file.
Post by: stahta01 on May 12, 2011, 04:12:54 pm
This is the one that covers your question.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F