-
November 9th, 2010, 05:43 AM
#1
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?
-
November 9th, 2010, 06:26 AM
#2
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.
-
November 9th, 2010, 01:31 PM
#3
Re: GNU compiler question
Thank you. I'm happy I can achieve the folder organization I want.
-
November 9th, 2010, 02:11 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|