Menu

Adding Header Files

2007-01-16
2012-09-26
  • Nobody/Anonymous

    I need to add header files to DevC++. I tried copying the files into the include folder, and also into the the backward folder, which is nested in the include folder.

    These are the two places I could find the other header files.

    Does anyone know why I still get an error message that the file cannot be found when I try to compile a program.

    Thanks!

     
    • Wayne Keen

      Wayne Keen - 2007-01-16

      To the teacher posting this question.

      I encourage you, as I encourage all the teachers who use Dev to teach
      their class, to take the time to talk with us. There are things that
      we know about setups, and pitfalls (like spaces in paths) that we can
      help you with, so that you can focus on what you need to focus on, i.e.
      teaching your students to program.

      There is also a secondary motivation, as we have students who pass through
      here who try to get folks to do their homework for them. Some are almost
      asking for help, and some are just blatantly cheating. Seeing their
      teacher active in this forum could cut down on some of the latter.

      We don't mind helping your students, we will give hints etc. (which in
      most cases is actually harder than doing it for them) - we just try to
      avoid actually writing their programs for them.

      Wayne

       
    • Soma

      Soma - 2007-01-16

      My ESP says that you failed to snarfle the garfax.

      Soma

       
    • Wayne Keen

      Wayne Keen - 2007-01-16

      Add them to your project Luke!

      If you are not using a Project for a multiple file compile,
      you should be.

      And as Soma clearly stated, please take the time to look at a forum
      before posting. There is a thread here, titled "Please Read Before
      Posting a Question" - that has information about what you should include
      in a question to avoid meandering narratives that fail to convey
      the information needed.

      Wayne

       
      • Soma

        Soma - 2007-01-16

        "And as Soma clearly stated, please take the time to look at a forum
        before posting."

        O_o

        "as Soma clearly stated"

        o_O

        "clearly stated"

        ^_^

        I'm betting most people wouldn't agree.

        Soma

         
        • Wayne Keen

          Wayne Keen - 2007-01-16

          It was clear to me!

          Big :)

          Wayne

          p.s. My precognitive sense is indicating that an ascerbic response is coming
          from the OP, indicating that the responses received were sub-optimal in
          clarity and suffered from excessive jocularity.

           
    • Nobody/Anonymous

      I am using cdev version 4.9.9.2 and Windows XP.

      Thanks for the help on how to post a question. I read the instructions and hope the following post is better.

      I need to add header files to the compiler that are not available. I downloaded them and copied them to the header folder and the backward folder.

      This is what happened when I ran the program.

      Calculates the area of a circle using the formula A=pirr
      A Student, 7/13/97 */

      include <cstdlib>

      include <iostream>

      include <bool>

      using namespace std;

      int main()
      {
      cout << "-Calculate the area of a circle-" << endl;
      cout << endl;
      cout << "Radius = " << 10 << endl;
      cout << "Area = " << (3.141010) << endl;
      system("PAUSE");
      return 0;
      }

      Compiler: Default compiler
      Building Makefile: "H:\DevC++\Chapter Two\circlearea\Makefile.win"
      Executing make...
      make.exe -f "H:\DevC++\Chapter Two\circlearea\Makefile.win" all
      g++.exe -c circleArea.cpp -o circleArea.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
      circleArea.cpp:8:16: bool: No such file or directory
      make.exe: *** [circleArea.o] Error 1
      Execution terminated

      I would appreciate help on what else I need to do to have the compiler include this header file.

      Thank you.

      Ted

       
    • Wayne Keen

      Wayne Keen - 2007-01-16

      You need, as I stated earlier to add your header files to your project
      Its really that simple.

      Project:Add to Project

      On an unrelated to the error, but important note:

      Note that it is a REALLY bad idea to keep your code in a directory
      with spaces in the path, i.e.

      H:\DevC++\Chapter Two\circlearea

      (I think I made note of that in the thread I pointed you to)

      Wayne

       
    • Anonymous

      Anonymous - 2007-01-16

      What is <bool>? By convention only C++ standard library headers have no extension, your own headers should have a .h extension (conventionally, you can flaut convention if you which to confuse). If it did not find this file, either you did not put it wher you say, or it is not called bool (bool.h perhaps?)

      If these are project related header files you should place them in your project folder rather than polute the Dev-C++ installation, and then include it thus #include "bool.h". If the sourcefile and the header are in the same folder it will be found, if you use a different folder for includes, you need to an a -I<path> compiler option to point to the folder.

      The code you posted does not require any thing other that that in <cstdlib> and <iostream>, so you could solve the problem simply by removing #include <bool>!

      Contrary to what Wayne has suggested I don't think adding headers to your project has any affect other than placing them in the project pane for easy editing. It does not affect the build. I may be wrong, but that is how I remember it, and use it.

      Clifford

       
      • Wayne Keen

        Wayne Keen - 2007-01-16

        What he said.

        :)

        Wayne

         
        • Wayne Keen

          Wayne Keen - 2007-01-16

          Seriously though, has your instructor indicated that you need ot include
          "bool" in every program?

          Or did it just get in there through an erroneous copy and paste?

          Or did you just add it to code that you knew otherwise worked?

          Wayne

           
    • Soma

      Soma - 2007-01-16

      I have all my fingers and toes crossed in the hope that you are not trying to learn C++ from the ancient and horrible "Teach Yourself Visual C++ in 21 Days". If so, please let us know, we can point out millions of better alternatives.

      Where did you get these files? If you have extensions turned off, the default, you will not see any extension in 'Explorer'. As Clifford pointed out, it is very likely that the file will have a '.h' extension.

      In any event, C++ has a built-in 'bool' type and doesn't need a header. What is this file supposed to do?

      Soma

       
    • Nobody/Anonymous

      Thanks for your help.

      I was not able to get it to work as you suggested.

      It may have to do with the header files themselves. The book I am using is out of print, and the C++ compiler, Turbo 4.5 is no longer available. The header files came from the books website.

      I am a high school teacher trying to get this class together for the second semester using the resources (i.e. book) that I have available to me. I am going to use what works and skip the rest, which isn't much. The only header files I have seen so far that I need are bool, random, and conio.

      Anyway, just a brief explanation and thank you for your help. I am going to let it go, as we will be getting new resources for the 07-08 school year.

      Thank you very much.

       
      • Soma

        Soma - 2007-01-16

        Hope so often fails to follow through.

        I could not have imagined that you would actually have an even worse book than I had thought. One of the worst programming books ever written for one of the best pre-standard compilers*. How strange the world works. I have a sheepish desire to hide under my bed.

        Clifford has a habit of linking the freely available book by Bruce Eckel named "Thinking in C++". Despite the book's flaws, it will be far superior to what you have. Even if he doesn't you can certainly find it with a simple search.

        Also, the files in question as shipped from Borland had a '.h' extension and all three are available built with MGW in mind. A link is available from the "Read Me" thread you claimed to have read.

        Soma

        • As far as I am concerned Borland Turbo C++ 4.5 is better than the post-standard Microsoft Visual C++.
         
    • Wayne Keen

      Wayne Keen - 2007-01-16

      "The book I am using is out of print, and the C++ compiler, Turbo 4.5 is no longer available. The header files came from the books website."

      Note that that compiler predates the ANSI standard by quite a bit.

      Note also that headers are not much in and off themselves, they are (for the most part) just recipes, and should contain little or no code at this level. So the idea that, by including a header, one gets what they need to actually do something is a potential problem. Along with a header there is frequently associated a .cpp file, or a compiled library.

      In the thread titled "Please Read Before Posting a Question", there is a section on useful links - one can find in there a number of good, useful online books and tutorials that are free.

      Wayne

       
    • Nobody/Anonymous

      I saw your other posts as I was composing my last post.

      Wayne, you were right about the bool being added to a small simple program that I knew worked.

      I just need the random number to be able to generate numbers for a program where we make a blackjack game.

      As I mentioned before, these files are on the books website, lpdatafiles. com.

      The book I am using for my class is "A Guide to Programming in C++ by Lawrenceville Press. I emailed the author of the book, but she told me that they are not longer supporting the book, as it is out of print.

      As far as the extensions go, I tried <bool> <bool.h> "bool" and "bool.h" in my include line everytime I made a change that I thought might help.

      I used #include <bool> because I saw that was how it was done in the default code that appears when you begin a new project.

      Thanks again, and thanks a lot. If you do have any further suggestions I would appreciate it, as it would make class go a lot smoother if I could follow the book exactly.

       
    • Anonymous

      Anonymous - 2007-01-16

      Oh no! Not the dreaded Lawrenceville Press again! It is out of print to a very good reason. It was discussed at length last month when a student posted a similar question, in the end his tutor gon involved also! See http://sourceforge.net/forum/forum.php?thread_id=1623380&forum_id=48211

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.