Hi all ROOTers
I have a problem with compiling outside of ROOT. I have a code written in
c, and I wish to store its output in a TTree.
Now, In order to do that I need to add certain ROOT classes in the existing
c-code. For that reason I consulted the Makefile example in the ROOT directory
/test which is used for i.e. Event.cxx.
I edited that Makefile to fit my purposes. The most important part is ofcourse
to link to the correct ROOT directories. The stripped down Makefile worked for
compiling Event.cxx (the the EVENTSO etc were present…)
I am not very experienced in Makefiles (or C programming for that matter).
Below is my edited Makefile:
ROOTCONFIG := root-config
ARCH := $(shell $(ROOTCONFIG) --arch)
PLATFORM := $(shell $(ROOTCONFIG) --platform)
ROOTCFLAGS := $(shell $(ROOTCONFIG) --cflags)
ROOTLDFLAGS := $(shell $(ROOTCONFIG) --ldflags)
ROOTLIBS := $(shell $(ROOTCONFIG) --libs)
ROOTGLIBS := $(shell $(ROOTCONFIG) --glibs)
HASTHREAD := $(shell $(ROOTCONFIG) --has-thread)
CC = gcc
CFLAGS = -w -g -c -O -I../inc
LD = gcc
LFLAGS = -g
SOFLAGS = -shared
CFLAGS += $(ROOTCFLAGS)
LFLAGS += $(ROOTLDFLAGS)
LIBS = $(ROOTLIBS) $(SYSLIBS)
GLIBS = $(ROOTGLIBS) $(SYSLIBS)
all: myCode
mbs2asc: myCode.o extra.o byte.o env.o
$(CC) $(LDFLAGS) $(LIBS) -o myCode extra.o byte.o env.o
clean:
rm -f myCode *.o
.c.o:
$(CC) $(CFLAGS) -o $@ $<
@echo "$@ done"
upon
make all
it works fine, and I get an executable myCode which works. BUT when trying i.e.:
#include "TTree.h"
or something else ROOT related
in myCode.c
I get a HUGE error message (which in my experience alwasy is caused by a very
fundamental error)
make all
gcc -w -g -c -O -I…/inc -pthread -I/usr/local/root/include -o myCode.o myCode.c
In file included from /usr/local/root/include/Rtypes.h:30,
from /usr/local/root/include/TObject.h:31,
from /usr/local/root/include/TNamed.h:26,
from /usr/local/root/include/TDirectory.h:25,
from /usr/local/root/include/TROOT.h:29,
from myCode.c:1:
/usr/local/root/include/Rtypeinfo.h:32:20: typeinfo: No such file or directory
In file included from /usr/local/root/include/Rtypes.h:30,
from /usr/local/root/include/TObject.h:31,
from /usr/local/root/include/TNamed.h:26,
from /usr/local/root/include/TDirectory.h:25,
from /usr/local/root/include/TROOT.h:29,
from myCode.c:1:
/usr/local/root/include/Rtypeinfo.h:33: error: syntax error before "std"
In file included from /usr/local/root/include/TObject.h:31,
from /usr/local/root/include/TNamed.h:26,
from /usr/local/root/include/TDirectory.h:25,
from /usr/local/root/include/TROOT.h:29,
from myCode.c:1:
/usr/local/root/include/Rtypes.h:39: error: syntax error before “TClass”
/usr/local/root/include/Rtypes.h:40: error: syntax error before “TBuffer”
.
.
.
.
In file included from /usr/local/root/include/Rtypes.h:234,
from /usr/local/root/include/TObject.h:31,
from /usr/local/root/include/TNamed.h:26,
from /usr/local/root/include/TDirectory.h:25,
from /usr/local/root/include/TROOT.h:29,
from myCode.c:1:
/usr/local/root/include/TGenericClassInfo.h:31: error: syntax error before ‘&’ token
/usr/local/root/include/TGenericClassInfo.h:34: error: syntax error before “TVirtualIsAProxy”
/usr/local/root/include/TGenericClassInfo.h:42: error: syntax error before “TClassStreamer”
/usr/local/root/include/TGenericClassInfo.h:46: error: syntax error before “public”
/usr/local/root/include/TGenericClassInfo.h:71: error: syntax error before ‘~’ token
.
.
.
.
continuing several hundreds of lines!!
I should mention that I have managed to compile everything in the test
directory and the tutorials work fine, so my ROOT 5.08 on Linux SuSe 9.3
with gcc 3.3.5 is Ok.
The lib*.so shouldnt be needed at this stage right? Since I only want to
compile arbitrary c code with some ROOT classes and not any TTrees as for now.
What should I do to move on. I have tried looking through other entries in the
forum.
I should mention that I need to compile it outside of ROOT, therefore havent tried anything inside ROOT, i.e. ACliC etc…
I hope I included all the information needed to define my problem completely
Best Regards!
Andreas