News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Cannot include user's custom header file.

Started by 71GA, December 19, 2010, 02:03:33 PM

Previous topic - Next topic

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:

#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

MortenMacFly

Quote from: 71GA on December 19, 2010, 02:03:33 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

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.

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.
(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!]

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]