How to configuration MakeFile to use library (TTree) from ROOT

In the question:
Save output in the TTree ROOT

I could not fix the problem, as in the moment
I understand much more the problem.
This question can help to solve the problem.

How to change the MakeFile to call library TTree
from ROOT to save the output from pythia in the file.root

What I did in the MakeFile:

FLAGS = -w -I/opt/root6/include -I../include -O2  -pedantic -W -Wall -Wshadow -fPIC -L../lib -Wl,-rpath,../lib -lpythia8 -ldl  `root-config --cflags` -Wl,-rpath,./ -Wl,-rpath,/opt/root6/lib `/opt/root6/bin/root-config --glibs`
...

# Examples without external dependencies.
main% : main%.cc $(PREFIX_LIB)/libpythia8.a
	$(CXX) $< -o $@ $(CXX_COMMON) $(FLAGS)

In the pythia/example this MakeFile there is one target
for main92.cc where work very well to save the output in the file.root

# ROOT (turn off all warnings for readability).
main91: $$@.cc $(PREFIX_LIB)/libpythia8.a
ifeq ($(ROOT_USE),true)
	$(CXX) $< -o $@ -w -I$(ROOT_INCLUDE) $(CXX_COMMON)\
	 `$(ROOTBIN)root-config --cflags`\
	 -Wl,-rpath,$(ROOT_LIB) `$(ROOT_BIN)root-config --glibs`
else
	@echo "Error: $@ requires ROOT"
endif
main92: $$@.cc $(PREFIX_LIB)/libpythia8.a main92.so
ifeq ($(ROOT_USE),true)
	$(CXX) $< main92.so -o $@ -w -I$(ROOT_INCLUDE) $(CXX_COMMON)\
	 `$(ROOTBIN)root-config --cflags` -Wl,-rpath,./\
	 -Wl,-rpath,$(ROOT_LIB) `$(ROOT_BIN)root-config --glibs`
else
	@echo "Error: $@ requires ROOT"
endif
main92.so: main92Dct.cc $(PREFIX_LIB)/libpythia8.a
	$(CXX) $< -o $@ -w -I$(ROOT_INCLUDE) $(CXX_SHARED) $(CXX_COMMON)\
	 `$(ROOTBIN)root-config --cflags`
main92Dct.cc: main92.h main92LinkDef.h
	export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(ROOT_LIB);\
	 $(ROOT_BIN)rootcint -f $@ -c -I$(PREFIX_INCLUDE) $^

# User-written examples for tutorials, without external dependencies.
mymain% : mymain%.cc $(PREFIX_LIB)/libpythia8.a
	$(CXX) $< -o $@ $(CXX_COMMON)

# Internally used tests, without external dependencies.
test% : test%.cc $(PREFIX_LIB)/libpythia8.a
	$(CXX) $< -o $@ $(CXX_COMMON)

# Clean.
clean:
	@rm -f main[0-9][0-9]; rm -f out[0-9][0-9];\
	rm -f main[0-9][0-9][0-9]; rm -f out[0-9][0-9][0-9];\
	rm -f mymain[0-9][0-9]; rm -f myout[0-9][0-9];\
	rm -f test[0-9][0-9][0-9]; rm -f *.dat\
	rm -f weakbosons.lhe; rm -f Pythia8.promc; rm -f hist.root;\
	rm -f *~; rm -f \#*; rm -f core*; rm -f *Dct.*; rm -f *.so;

I’m using root:

  • ROOT 6.13/01 Built for linuxx8664gcc From heads/master@v6-11-02-2013-gd639b6a, Mar 09 2018, 10:15:08

Someone can help me?

Cheers, Andre

Your main link line need to also contains the output of root-config --libs

Cheers,
Philippe.

Hi, Philippe.

Thanks for the reply. It worked.

I use the model main92.cc and the main92Dct, … for
created target for main112.cc in the Makefile.

  • Makefile:
main112: $$@.cc $(PREFIX_LIB)/libpythia8.a main112.so
ifeq ($(ROOT_USE),true)
	$(CXX) $< main112.so -o $@ -w -I$(ROOT_INCLUDE) $(CXX_COMMON)\
	 `$(ROOTBIN)root-config --cflags` -Wl,-rpath,./\
	 -Wl,-rpath,$(ROOT_LIB) `$(ROOT_BIN)root-config --glibs`
else
	@echo "Error: $@ requires ROOT"
endif
main112.so: main112Dct.cc $(PREFIX_LIB)/libpythia8.a
	$(CXX) $< -o $@ -w -I$(ROOT_INCLUDE) $(CXX_SHARED) $(CXX_COMMON)\
	 `$(ROOTBIN)root-config --cflags`
main112Dct.cc: main112.h main112LinkDef.h
	export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(ROOT_LIB);\
	 $(ROOT_BIN)rootcint -f $@ -c -I$(PREFIX_INCLUDE) $^
	 

and the ($FLAGS):

FLAGS = -w -I/opt/root6/include -I../include -O2  -pedantic -W -Wall -Wshadow -fPIC -L../lib -Wl,-rpath,../lib -lpythia8 -ldl  `root-config --cflags` -Wl,-rpath,./ -Wl,-rpath,/opt/root6/lib `/opt/root6/bin/root-config --glibs`

# Examples without external dependencies.
main% : main%.cc $(PREFIX_LIB)/libpythia8.a
	$(CXX) $< -o $@ $(CXX_COMMON) $(FLAGS)

Run:

$ sudo make main112
g++ main112Dct.cc -o main112.so -w -I/opt/root6/include -shared -I../include -O2  -pedantic -W -Wall -Wshadow -fPIC -L../lib -Wl,-rpath,../lib -lpythia8 -ldl \
 `root-config --cflags`
g++ main112.cc main112.so -o main112 -w -I/opt/root6/include -I../include -O2  -pedantic -W -Wall -Wshadow -fPIC -L../lib -Wl,-rpath,../lib -lpythia8 -ldl \
 `root-config --cflags` -Wl,-rpath,./\
 -Wl,-rpath,/opt/root6/lib `/opt/root6/bin/root-config --glibs`

Cheers, Andre

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