User forums > Using Code::Blocks

Cannot include user's custom header file.

(1/2) > >>

71GA:
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();
}

--- End code ---

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

MortenMacFly:

--- Quote from: 71GA on December 19, 2010, 02:03:33 pm ---Anyone knows how I can solve this problem? TY

--- End quote ---
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.

71GA:

--- Quote from: MortenMacFly on December 19, 2010, 02:10:17 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.

--- End quote ---

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:
Since this is such a common question. It might be good to give this a special place in the FAQ's.

oBFusCATed:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version