Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include files

Status
Not open for further replies.

Disruptive

Programmer
Mar 8, 2005
40
GB
Hi

I have include files that are stored in the following way. How do I access them when reffering to them in the include file?

/main
make files
main/dir1
xyz.c
xyz.h
main/dir2
123.c
123.h

How do I refer to the xyz header file from the dir two directory? Any help would be most appreciated/. I am usinf Linux as a development tool and the g++ compiler.
 
You would just do :

#include "xyz.h"

and when compiling use the switch 'I' to include that directory, eg :

g++ main/dir1/*.c main/dir2/*.c -Imain/dir1 -Imain/dir2 -o whatever

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
How would a make file look for something like that?

Thanks
 
Thanks for the link, but it does not seem to cover include files and different files in different directories.
 
Well, there are lots of other tutorials out there - have a look around maybe ?

Or, you could try using what you have learnt in that tutorial, and use a bit of trial and error to achieve your goals.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I now have a suitable make file....

However with my include files, I need to refer to one header file but its not in each of the subdirectories. I cannot seem to get something like:

"../Vars/variables.h" working.

Any ideas. Each file needs to look at a central file that is NOT in the same directory, its up one level. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top