Compilation error: undefined reference to TPaletteAxis::GetBinColor

Hello root friends,

I am trying to compile a small code using g++ with a makefile and I get the following error:

Compiling HexPlot.cxx
THex.o: In function `THex::DrawHexagons(std::string)':
THex.cxx:(.text+0x1325): undefined reference to `TPaletteAxis::GetBinColor(int, int)'
collect2: error: ld returned 1 exit status
make: *** [HexPlot] Error 1

The lines in my code that presumably create this error are:

	TPaletteAxis *palette = (TPaletteAxis*)h_vals->GetListOfFunctions()->FindObject("palette");
	Int_t ci=palette->GetBinColor(binx,biny); //this is the line crucial line!
	// Int_t ci=0; //this line works

…following the example in the TPaletteAxis::GetBinColor documentation. When I comment the second to last line out and uncomment the last line it works. Also, compilation in cint using .L mycode.C++ works fine. Do you have a suggestion what I could do? I attach all files I use for compilation below. My makefile is this:

# Compiler
CXX           = $(shell root-config --cxx)

# Compiler flags
ROOTCFLAGS   := $(shell root-config --cflags)
ROOTLIBS     := $(shell root-config --libs)
LFLAGS        = -O3 ${ROOTLIBS}

# Targets
EXE = HexPlot
OBJS = HexPlot.o THex.o

# Compile core, user algorithms and make an executable for each user algorithm
all: ${OBJS} ${EXE}
	@echo "Done"

${EXE}: ${OBJS}
	@echo "Making executable $(notdir $@)"
	@echo @${CXX} ${CFLAGS} ${OBJS} ${LFLAGS} -o $@
	@${CXX} ${CFLAGS} ${OBJS} ${LFLAGS} -o $@

${EXE}.o: ./${EXE}.cxx
	@echo "Compiling $(notdir $<)"
	@echo @${CXX} $(CFLAGS) -c $< -o $@ 
	@${CXX} $(CFLAGS) -c $< -o $@ 

%.o: ./%.cxx ./%.h
	@echo "Compiling $(notdir $<)"
	@echo @${CXX} $(CFLAGS) -c $< -o $@ 
	@${CXX} $(CFLAGS) -c $< -o $@ 

	@rm -f ./HexPlot
	@rm -f ./
	@rm -f ./HexPlot_C.d
	@rm -f ./*.o
	@echo "Cleaning"

THex.cxx (975 Bytes)
THex.h (334 Bytes)
HexPlot.cxx (218 Bytes)

LFLAGS = -O3 ${ROOTLIBS} -lHistPainter

Thank you! That solved it!

Why isn’t lHistPainter included in root-config --libs and how can I infer from a similar error message which I might get in future that I have to include another library?

grep -l TPaletteAxis root-config --libdir/*.rootmap