Makefile with ROOT libraries

Hi!
First time I write on this forum but used it quite a lot in the past (thanks you for its existence :smiley:)

Iā€™m writing a stand alone program that required ROOT libraries to work on TFiles.
The first part that uses just c++ functions worked very well and I havenā€™t any problem with make command.
When I add a function that required TFiles.h and ā€œTTree.hā€ (but also just adding the corrispective #inlcude in the header) it stop working.

This is the error message after doing make on terminal

g++ -L /usr/include/boost root-config --glibs -o CSEXE ConfigFile.o CS.o Sorter.o SortRun.o -lboost_system -lboost_filesystem -lboost_thread
CS.o: In function __static_initialization_and_destruction_0': /gate/root/include/TVersionCheck.h:34: undefined reference toTVersionCheck::TVersionCheck(int)ā€˜
Sorter.o: In function __static_initialization_and_destruction_0': /gate/root/include/TVersionCheck.h:34: undefined reference toTVersionCheck::TVersionCheck(int)ā€™

This is my makefile:

CXXFLAGS += -I /usr/include/boost root-config --cflags
LDFLAGS += -L /usr/include/boost root-config --glibs
CPPFLAGS += -MD -MP -ansi -pedantic -Wall -g

SOURCES := $(wildcard *.cc)

CSEXE: $(SOURCES:%.cc=%.o)
$(CXX) $(LDFLAGS) -o $@ $^ -lboost_system -lboost_filesystem -lboost_thread
rm -rf *.d *.o
-include $(SOURCES:%.cc=%.d)

clean:
rm -rf *EXE *.d *.o

Some information:
I always do the source of the .sh file in the root folder.

Everything works properly when I compile my single file programs with:
g++ -Wall -ansi myfile.cxx -o myfileEXE root-config --cflags --glibs

Reading somewhere on the forum I have done a check (I donā€™t know if it is usefull): writing root-config --glibs on terminal I obtain this error
-bash: -L/gate/root/lib: No such file or directory

instead of the list of classes.

I ask for your help because Iā€™m very newbie on makefile and all that stuff :slight_smile:

Try with:
CSEXE: $(SOURCES:%.cc=%.o)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lboost_system -lboost_filesystem -lboost_thread
See also: [url]Compiling Root script with g++

Thank you!!! It worked!
As I tought I messed up with the makefile!

Thanks again!