# Makefile add include directory

**URL:** <https://root-forum.cern.ch/t/makefile-add-include-directory/7893>\
**Category:** ROOT\
**Created:** [February 19, 2009, 10:17pm UTC](https://root-forum.cern.ch/t/makefile-add-include-directory/7893 "2009-02-19T22:17:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedesuarez](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/9de0a6/32.png) [@fedesuarez](https://root-forum.cern.ch/u/fedesuarez)\
**Post date:** [February 19, 2009, 10:17pm UTC](https://root-forum.cern.ch/t/makefile-add-include-directory/7893/1 "2009-02-19T22:17:46Z")

</div>

Hi,

it may be a dumb question but I can’t figure it out… I have a folder with a lot of .cxx and .h file and everything compile perfectly. Then I wanted to move the .h files to a ./include folder. So, after moving the .h files the folder looks like this:

```auto
Doxyfile_pmttest ls.cxx Makefile oscilloscope.cxx serial.o spe.o
error ls.o Makefile.arch oscilloscope.o signal.cxx
guitest.o main.cxx open.cxx PMT signal.o
include main.o open.o serial.cxx spe.cxx
```

Then, I tried to add the include folder into the makefile which looks like this:

```auto
include Makefile.arch

CXXFLAGS +=-I/usr2/fuentes/PMTtest/include

mainO = main.$(ObjSuf)
mainS = main.$(SrcSuf)
main = PMT$(ExeSuf)
openO = open.$(ObjSuf)
openS = open.$(SrcSuf)
lsO = ls.$(ObjSuf)
lsS = ls.$(SrcSuf)
serialO = serial.$(ObjSuf)
serialS = serial.$(SrcSuf)
oscilloscopeO = oscilloscope.$(ObjSuf)
oscilloscopeS = oscilloscope.$(SrcSuf)
signalO = signal.$(ObjSuf)
signalS = signal.$(SrcSuf)
speO = spe.$(ObjSuf)
speS = spe.$(SrcSuf)

EXE_FILES = $(main)
OBJ_FILES = $(openO) $(lsO) $(serialO) $(oscilloscopeO) $(signalO) $(speO) $(mainO) 

$(main): $(OBJ_FILES)
		$(LD) $(LDFLAGS) $(OBJ_FILES) $(GLIBS) $(LIBS) $(OutPutOpt) $@
		@echo "$@ done"

.SUFFIXES: .$(SrcSuf)

.$(SrcSuf).$(ObjSuf):
	$(CXX) $(CXXFLAGS) -c $<

.PHONY : clean
clean:
	rm $(OBJ_FILES) $(EXE_FILES)
```

Then, when I try to compile it fails and gives a huge error list:

```auto
fede@jenna:/usr2/fuentes/PMTtest$ make
g++ -O2 -Wall -fPIC -pthread -m32 -I/usr/include/root -I/usr2/fuentes/PMTtest/include -c open.cxx
In file included from /usr/include/c++/4.2/bits/char_traits.h:46,
                 from /usr/include/c++/4.2/string:47,
                 from /usr2/fuentes/PMTtest/include/signal.h:9,
                 from /usr/include/pthread.h:29,
                 from /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h:43,
                 from /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h:114,
                 from /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h:43,
                 from /usr/include/c++/4.2/iosfwd:46,
                 from /usr/include/root/Riosfwd.h:33,
                 from /usr/include/root/TObject.h:40,
                 from /usr/include/root/TNamed.h:26,
                 from /usr/include/root/TDirectory.h:25,
                 from /usr/include/root/TROOT.h:29,
                 from /usr2/fuentes/PMTtest/include/open.h:8,
                 from open.cxx:7:
/usr/include/c++/4.2/bits/stl_algobase.h:321: error: ‘ostreambuf_iterator’ was not declared in this scope
/usr/include/c++/4.2/bits/stl_algobase.h:321: error: template argument 2 is invalid
etc. etc. etc...
```

Could you please tell me how to add an include folder??? and a libraries folder???

Thanks

fede.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [February 19, 2009, 10:33pm UTC](https://root-forum.cern.ch/t/makefile-add-include-directory/7893/2 "2009-02-19T22:33:23Z")

</div>

Hi,

Your header file /usr2/fuentes/PMTtest/include/signal.h conflict with the system header on the same name (pthread.h needs it). Rename your file and the problem will go away.

Cheers,  
Philippe.

---

<div class="post-metadata">

**Author:** ![fedesuarez](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/9de0a6/32.png) [@fedesuarez](https://root-forum.cern.ch/u/fedesuarez)\
**Post date:** [February 19, 2009, 11:21pm UTC](https://root-forum.cern.ch/t/makefile-add-include-directory/7893/3 "2009-02-19T23:21:58Z")

</div>

OOOHHHH I’m an idiot!!! That fixed the problem. Thanks a lot!!!

fede.

---

<div class="post-metadata">

**Author:** ![cplager](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@cplager](https://root-forum.cern.ch/u/cplager)\
**Post date:** [February 20, 2009, 3:44pm UTC](https://root-forum.cern.ch/t/makefile-add-include-directory/7893/4 "2009-02-20T15:44:05Z")

</div>

For what it’s worth, if you put your own user include files in a subdirectory and access them that way, you are less likely to be bitten by this. For example:

```auto
#include "interface/signal.h"
```

is safer than

```auto
#include "signal.h"
```

Of course, once you’ve figured out that you have the same name as a standard include file, changing the name is probably a good idea regardless. 😃

Cheers,  
Charles
