Thread: Where can i add a header file other than include directory

  1. #1
    asdfasdfasdf
    Guest

    Where can i add a header file other than include directory

    I am trying to add my header file to a project I am working on but for some reason it says it can't find it (it's in the project folder). I don't want to add it to the include directory of the computer because I need it to be inside the project folder so I can work on it on other computers. It keeps saying it cannot find the header file, it's frustrating.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Did you
    #include <myfile.h>
    or did you
    #include "myfile.h"

    (the latter is correct for your use, I'd imagine)

    Also, I expect your compiler will have options for you to specify include directories.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    the "myheader.h" variety searches the current directory, so you can include subdirectories in the header name eg
    Code:
    #include "myheaders/header1.h"
    In theory you could find the header anywhere....
    Couldn't think of anything interesting, cool or funny - sorry.

  4. #4
    asdfasdf
    Guest
    I have tried both with and without the .h, isn't there a way to include it so that it doesn't matter where it is located on the hard drive? Can I add an include folder to my project or something so that it always looks there??? I really don't want to have to put the header files in the incldue directory of every computer I'm going to be working on (the actual project doesn't even get saved on the hard drive, it has to be edited on the hdd and then saved on the network until I edit it again).

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    what compiler and OS?

    > I have tried both with and without the .h
    without the .h won't work (I don't believe)

    >isn't there a way to include it so that it doesn't matter where it is located on the hard drive?
    Naturally you have to tell the compiler (via #include) where to get the file, but other than that, you can put it where you want (within reason).

    Personally, for my smaller projects, I have all the .h and .cpp files in the same directory, then just use #include "myfile.h" in the .cpp ones.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM