Compling c++ with root flags in ubuntu

I have some c++ code and a makefile that compiles on an old system running root5.34 that I’m trying to port over to a new Ubuntu machine. The c++ code was auto generated from a root TTree with the MakeClass option and as far as I can tell the problem is with the makefile/ubuntu.

my default makefile reads as:

OPT = -Wall
CXX = g++ $(OPT)
ROOTFLAGS =`root-config --glibs --cflags`
all: Process

Process: Process.o
        @echo " "
        @echo "Compiling"
        $(CXX) $(ROOTFLAGS) Process.o -o runProcess
        rm -f Process.o
Process.o: Process.cxx
        @echo " "
        @echo "Making Objects"
        $(CXX) $(ROOTFLAGS) -c Process.cxx

        rm -f Process.o
        rm -f runProcess

and compiling gives the error:

Making Objects
g++ -Wall `root-config --glibs --cflags` -c Process.cxx

g++ -Wall `root-config --glibs --cflags` Process.o -o runProcess
/usr/bin/ld: Process.o: in function `temp::temp(TTree*)':
Process.cxx:(.text+0x3f): undefined reference to `ROOT::GetROOT()'

In testing things out I removed the --cflags option which gives a no such file or directory error for TROOT.h

Does Ubuntu require a special setup to link the libraries properly?

ROOT Version: 6.18
Platform: Ubuntu 20.04


CXX := `root-config --cxx` $(OPT)
ROOTFLAGS :=`root-config --cflags`
ROOTLIBS :=`root-config --libs`

and then:
$(CXX) $(ROOTFLAGS) Process.o -o runProcess $(ROOTLIBS)

1 Like

Yeah that worked perfectly. Thanks for your help

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