I want to extend features of a histogram by inherit the TH1F class by the CTrack. I defined my class CTrack : public TH1F in CTrack.h and I implement it in CTrack.cpp. I wrote default constructor, copy constructor, I added ClassImp and ClassDef macros. I created LinkDef.h file. After compilation I’ve got libCTrack.so. When I want to use it in ROOT by .L libCTrack.so I have an error:
dlopen error: ./libCTrack.so: undefined symbol: _ZN4TH1F11ShowMembersER16TMemberInspector
Load Error: Failed to load Dynamic link library ./libCTrack.so
*** Interpreter error recovered ***
Can anybody help me?
I attached a very simple version of my class.
CTrack.tar.gz (40.1 KB)
Your compilation is not complete.
You have to create an output file for your dictionary and include this in the compilation of the library.
This is the modified Makefile that worked for me (sorry for messing up with your short cuts):
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
CFLAGS = -fPIC
SOURCES = CTrack.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECUTABLE = libCTrack.so
all: cTrackDict.cpp $(OBJECTS) $(EXECUTABLE)
cTrackDict.cpp: CTrack.h cTrackLinkDef.h
rootcint -f $@ -c CTrack.h cTrackLinkDef.h
$(CC) $(CFLAGS) $(ROOTCFLAGS) -c cTrackDict.cpp -o cTrackDict.o
$(CC) $(CFLAGS) $(ROOTGLIBS) -shared cTrackDict.o CTrack.o $(ROOTCFLAGS) -o $@
$(CC) -c $(CFLAGS) $< $(ROOTCFLAGS) -o $@
@rm -f $(EXECUTABLE) $(OBJECTS) *Dict*
Yes you are right. I forgot, my mistake. Now It works,