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:
gPad->Update();
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)
CFLAGS = -Wall ${ROOTCFLAGS} ${INCLUDE_PATH}
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 $@
clean:
@rm -f ./HexPlot
@rm -f ./HexPlot_C.so
@rm -f ./HexPlot_C.d
@rm -f ./*.o
@echo "Cleaning"
Cheers,
Andreas
THex.cxx (975 Bytes)
THex.h (334 Bytes)
HexPlot.cxx (218 Bytes)