Problem with including files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • unclefester
    New Member
    • Mar 2008
    • 12

    Problem with including files

    I have the following setup:

    Folder C contains...
    1. Folder A
    - A.cpp
    2. Folder B
    - Folder B1
    - B.h

    In A.cpp, I need to include B.h but I always get a No Such File or Directory error. I have tried

    Code:
    #include <B/B1/B.h>
    which I think is supposed to be correct but it still generates an error.
  • quophyie
    New Member
    • Mar 2008
    • 4

    #2
    Try #include "B\B1\B.h" instead (if you are uing windows). Using the"<>" symbols are is usually reserved for library header files
    Originally posted by unclefester
    I have the following setup:

    Folder C contains...
    1. Folder A
    - A.cpp
    2. Folder B
    - Folder B1
    - B.h

    In A.cpp, I need to include B.h but I always get a No Such File or Directory error. I have tried

    Code:
    #include <B/B1/B.h>
    which I think is supposed to be correct but it still generates an error.

    Comment

    • gpraghuram
      Recognized Expert Top Contributor
      • Mar 2007
      • 1275

      #3
      Originally posted by unclefester
      I have the following setup:

      Folder C contains...
      1. Folder A
      - A.cpp
      2. Folder B
      - Folder B1
      - B.h

      In A.cpp, I need to include B.h but I always get a No Such File or Directory error. I have tried

      Code:
      #include <B/B1/B.h>
      which I think is supposed to be correct but it still generates an error.
      You can include the file as #include"B.h" and in the include directory you can add the path of the B.h file.
      If using gcc/g++ use -I option

      Raghuram

      Comment

      • unclefester
        New Member
        • Mar 2008
        • 12

        #4
        Originally posted by quophyie
        Try #include "B\B1\B.h" instead (if you are uing windows). Using the"<>" symbols are is usually reserved for library header files
        quophyie, I tried your suggestion but it didn't work. I'm using Linux btw.

        Comment

        • unclefester
          New Member
          • Mar 2008
          • 12

          #5
          Originally posted by gpraghuram
          You can include the file as #include"B.h" and in the include directory you can add the path of the B.h file.
          If using gcc/g++ use -I option

          Raghuram
          Raghuram, I'm having problems because the program is using a makefile for compilation. How do I specify it in a makefile?

          Comment

          Working...