You seem to have the following structure:
whatever/
list/
...
list.h
...
queue/
... <- some files have an #include "list/list.h";
list/ <- duplicate
tree/
rootedTree/
...
list/ <- duplicate
tree.h <- has an #include "list/list.h";
test.c <- #include "tree.h"
In this code, you first go to the folder where you want to compile things, and then compile them inside the folder:
you@somewhere:~/whatever/tree/rootedTree$ gcc -Wall -I. -g *.c -o test
The paths of the #include
statements are relative to where the compiler is invoked from (as long as you include the -I.
argument; thanks, @jean-françois-fabre). So you can very well have the following (non-duplicated) structure:
whatever/
list/
...
list.h
...
queue/
... <- some files have an #include "list/list.h"; no list/ duplicate
tree/
rootedTree/
...
tree.h <- has an #include "list/list.h"; no list/ duplicate
testTree.c <- #includes "tree/rootedTree/tree.h" and others
and, from within the whatever folder, you can write
you@somewhere:~/whatever$ gcc -Wall -I. -g */*.c testTree.c -o testTree
and get an executable to test. Since calling the compiler directly is boring, especially if you only want to compile the parts of the code where you have actually made changes, you generally use some sort of project definition file (Makefile, Scons, ...) to handle that for you.
Duplication is bad, and there is (almost) always a way to avoid it.