Error: TFile.h: No such file or directory

I try to convert an .cc file to .e using code:

PROGNAME = ks_4MeV.e
SOURCEFILES = ks_4MeV.cc

OBJS = $(patsubst %.cc, %.o, $(SOURCEFILES))

ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)

LDFLAGS = -O
LIBS += $(ROOTLIBS)
CFLAGS += $(ROOTCFLAGS)

%.o: %.cc
g++ -Wall ${CFLAGS} -c -g -o $@ $<

$(PROGNAME): $(OBJS)
g++ -Wall -o $@ $(OBJS) $(LDFLAGS) $(LIBS) -lGeom

test:
@echo $(ROOTCFLAGS)

clean:
-rm -f ${PROGNAME} ${OBJS}

and this error was reported:

make: root-config: Command not found
make: root-config: Command not found
make: root-config: Command not found
g++ -Wall  -c  -g -o ks_4MeV.o ks_4MeV.cc
ks_4MeV.cc:4:10: fatal error: TFile.h: No such file or directory
 #include "TFile.h"
          ^~~~~~~~~
compilation terminated.
GNUmakefile:15: recipe for target 'ks_4MeV.o' failed
make: *** [ks_4MeV.o] Error 1

Up to now I used same code on my old computer and it was working excellent, but when I tray it on new one, I receive mentioned message.
Please can you help me?


Please read tips for efficient and successful posting and posting code

ROOT Version: v6 16.00
Platform: Linux-Ubuntu v18.04ks_4MeV.cc (24.9 KB)
Compiler: Not Provided


You should change the following for g++ to find the ROOT headers:

INC := (shell root-config --incdir)

%.o: %.cc
g++ -Wall {CFLAGS} -I$(INC) -c -g -o @ $<

The message “root-config: Command not found” says that you did not setup your ROOT properly.

Sorry, this did no work…

I just installed root on my computer and it is running properly.
Can you explain me more precise how to fix this?

Did you source thisroot.sh before running make?

source <install_directory>/bin/thisroot.sh

No, this is first time since I installed root.

Ok I added this line to .profile file and I get this message:
g++ -Wall -o ks_4MeV.e ks_4MeV.o -O -L/home/aleksandra/root/lib -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -pthread -lm -ldl -rdynamic -lGeom
/usr/bin/ld: warning: libtbb.so.2, needed by /home/aleksandra/root/lib/libImt.so, not found (try using -rpath or -rpath-link)
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::task_group_context::cancel_group_execution()' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::interface5::internal::task_base::destroy(tbb::task&)’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::task_scheduler_init::initialize(int)' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::task::note_affinity(unsigned short)’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::task_group_context::is_group_execution_cancelled() const' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::internal::allocate_continuation_proxy::allocate(unsigned long) const’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::internal::throw_exception_v4(tbb::internal::exception_id)' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::task_scheduler_init::terminate()’
/home/aleksandra/root/lib/libImt.so: undefined reference to typeinfo for tbb::task' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::task_group_context::reset()’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::interface7::internal::task_arena_base::internal_terminate()' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::task_group_context::init()' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::internal::allocate_additional_child_of_proxy::allocate(unsigned long) const’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::interface7::internal::isolate_within_arena(tbb::interface7::internal::delegate_base&, long)' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::task_scheduler_init::default_num_threads()’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::interface7::internal::task_arena_base::internal_initialize()' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::internal::get_initial_auto_partitioner_divisor()’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::task_scheduler_init::initialize(int, unsigned long)' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::task_group_context::~task_group_context()’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::internal::allocate_child_proxy::allocate(unsigned long) const' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const’
/home/aleksandra/root/lib/libImt.so: undefined reference to tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const' /home/aleksandra/root/lib/libImt.so: undefined reference totbb::internal::allocate_additional_child_of_proxy::free(tbb::task&) const’
collect2: error: ld returned 1 exit status
GNUmakefile:18: recipe for target ‘ks_4MeV.e’ failed
make: *** [ks_4MeV.e] Error 1
when I run script.

Try:
sudo apt-get install libtbb-dev

Now I got this one:

g++ -Wall -o ks_4MeV.e ks_4MeV.o -O -L/home/aleksandra/root/lib -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -pthread -lm -ldl -rdynamic -lGeom

/home/aleksandra/root/lib/libImt.so: undefined reference to `tbb::interface7::internal::isolate_within_arena(tbb::interface7::internal::delegate_base&, long)’
collect2: error: ld returned 1 exit status
GNUmakefile:18: recipe for target ‘ks_4MeV.e’ failed
make: *** [ks_4MeV.e] Error 1

Try:

LDFLAGS = $(shell root-config --ldflags)
LIBS += $(ROOTLIBS) -ltbb

That worked!
Thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.