first of all, I’ve got a macro “file.cxx”. Most of the time I just let root interpret it. Therefore I need to load AtlasStyle and a file which was created because I used MakeClass. So in the terminal I start root and than .L AtlasStyle.C and .L myclass.C.
Now I want to compile the macro, and I made a makefile. Since this is my first one, I’ve got a few problems.
This is my makefile:
CFLAGS = $(shell root-config --cflags)
LIBS = $(shell root-config --libs)
GLIBS = $(shell root-config --glibs)
all: macro
clean:
rm -f *.o macro
macro : macro.o myclass.o myheader.o #in myheader.h is a function I use defined
g++ -o $@ $+ $(CFLAGS) $(LIBS) $(GLIBS)
myclass.o : myclass.C myclass.h
myheader.o : myheader.h
macro.o : macro.cxx myclass.h myheader.h
If I type “make” in the terminal the following error occurs:
g++ -c -o myclass.o myclass.C
In file included from myclass.C:2:0:
myclass.h:11:19: fatal error: TROOT.h:File or directory not found
compilation terminated.
So, where did I do something wrong in the makefile? As I mentioned it’s the first time I work with make. And how do I load AtlasStyle.C?
I’ve also read the Root User’s Guide, and in chapter 3.4.2 there was something about compiling. Do I need a main-function in my macro?
It would be nice, if someone could say, how my makefile must look like, that it will work.
So, now I made make clean. And then run make again. This time it says:
g++ -pthread -m64 -I/usr/include/root -o myclass.o -c myclass.C
In file included from myclass.C:2:
myclass.h:28: error: ISO C++ forbids declaration of ‘vector’ with no type
myclass.h:28: error: expected ‘;’ before ‘<’ token
for every leave type in the TTree.
And
myclass.h: In member function ‘virtual void signal::Init(TTree*)’:
myclass.h:337: error: ‘Particle_PID’ was not declared in this scope
for every object pointer. I think this second error comes because of the first error. But I don’t know why there is the first error anyway…
line 28 is: vector<int> *Particle_PID;
line 337 is: Particle_PID = 0;
Edit: fixed this error with: using std::vector; at the beginning of myclass.h
I have done it by now :'D So yeah, I spent way to much time for that but now it works. I just had to figure out how my files are depending on each other, so now everything is fine It’s kinda hard for me to understand some of these things, because I’m doing it for the first time and it’s often “learning-by.doing” and this costs lot of time.