Adding -lGpad flag to roofitcore

Hey rooters
I am working on adding a new class called ‘RooMCMC’ to the roofitcore, but when I try to compile I get an undefined reference to TCanvas and TPad. If I look at the output:

RooFitCore.o -Llib -lCore -ldl -Llib -lHist -lGraf -lMatrix -lTree -lMinuit -lRIO -lMathCore -lFoam -pthread
roofit/roofitcore/src/RooMCMC.o: In function `RooMCMC::saveCornerPlotAs(char const*)':
RooMCMC.cxx:(.text+0x70be): undefined reference to `TCanvas::TCanvas(char const*, char const*, int, int, int, int)'
RooMCMC.cxx:(.text+0x7221): undefined reference to `TPad::TPad(char const*, char const*, double, double, double, double, short, short, short)'
RooMCMC.cxx:(.text+0x74eb): undefined reference to `TPad::TPad(char const*, char const*, double, double, double, double, short, short, short)'

I noticed that the -lGpad flag is missing, which should include TCanvas and TPad. I know its a bold question but how and where do I add this flag?

How do you build your executable? With a makefile?

It is the make file for building the whole root.

Do I understand then that you add your class directly in the sources of ROOT? In this case I would recommend you that you use the supported build method which is CMake (see https://root.cern.ch/building-root) and then you modify the file roofit\roofitcore\CMakeLists.txt adding the library Gpad to the lines

ROOT_STANDARD_LIBRARY_PACKAGE(RooFitCore
                              HEADERS ${headers1} ${headers2} ${headers3} ${headers4}
                              DICTIONARY_OPTIONS "-writeEmptyRootPCM"
                              DEPENDENCIES Core Hist Graf Matrix Tree Minuit RIO MathCore Foam)

Yes I did.
Ok Thanks for the advice. I will use another approach, I deleted the function using TCanvas then it compiled correctly and I will add it to a Tutorial where people can copy it from.

But Thank you very much for you help.