CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2010
    Posts
    2

    GNU compiler question

    I understand this is the C++ forum and to be honest posting here makes the most sense, but if I'm wrong I'm sorry.

    Anyways, I'm trying to figure out if the compiler can handle the separation of header files and source files into different directories and how I would tell it that one is somewhere else. Or does it basically require both source and header file to be in the same directory?

  2. #2
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: GNU compiler question

    Sources can be in different folders. It normally makes sense to have all new files belonging to a project in one branch so that you can work with relative paths. For headers of basic libraries you were using absolute paths (normally) or use the include environment variable.

    The compiler gets the information where to search for header files by the -I option, e. g.

    gcc -I ./include <more options>

    You can add the "-I folder" pair multiple times.

  3. #3
    Join Date
    Nov 2010
    Posts
    2

    Smile Re: GNU compiler question

    Thank you. I'm happy I can achieve the folder organization I want.

  4. #4
    Join Date
    Jan 2009
    Posts
    1,689

    Re: GNU compiler question

    You can also specify the path in the include
    Code:
    #include "../headers/myheader.h"
    A lot of libraries work that way.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured