Creating shared library : unresolved while linking [cling interface function]!

Hello!

I am trying to create a shared library including a new class that I created derived from TObject. I am following the instructions in root.cern.ch/root/html534/guide … Class.html

The library is called Histograms.so and it seems to compile but when I run my executable with root :

root -l -q createPlot.cxx’()’

and load the library using gSystem->Load(“Histograms.so”), I get the following message :

[size=85]
Processing createPlot.cxx()…
IncrementalExecutor::executeFunction: symbol ‘_ZN9Histogram12defineSelVarESsSsSt6vectorIdSaIdEEb’ unresolved while linking [cling interface function]!
You are probably missing the definition of Histogram::defineSelVar(std::string, std::string, std::vector<double, std::allocator >, bool)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘ZN9Histogram12fillFromFileE7TStringS0’ unresolved while linking [cling interface function]!
You are probably missing the definition of Histogram::fillFromFile(TString, TString)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN9Histogram15defineVariablesE7TStringSt6vectorIS0_SaIS0_EE’ unresolved while linking [cling interface function]!
You are probably missing the definition of Histogram::defineVariables(TString, std::vector<TString, std::allocator >)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN9Histogram6CreateESsiddiddidd’ unresolved while linking [cling interface function]!
You are probably missing the definition of Histogram::Create(std::string, int, double, double, int, double, double, int, double, double)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘ZN9Histogram8DrawHistE7TStringbS0’ unresolved while linking [cling interface function]!
You are probably missing the definition of Histogram::DrawHist(TString, bool, TString)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN9HistogramC1ESsSsSs’ unresolved while linking [cling interface function]!
You are probably missing the definition of Histogram::Histogram(std::string, std::string, std::string)
Maybe you need to load the corresponding shared library?
[/size]

I have seen some tickets also on this page that could be related and in JIRA (
sft.its.cern.ch/jira/browse/ROOT-7947 , Unresolved while linking function .. ERROR!)but in my case I am using a Makefile on lxplus and the problem does not appear while installing ROOT so I am not sure if the solution could be the same. MyROOT version is :

–rootVer=6.04/18 --cmtConfig=x86_64-slc6-gcc49-opt

I join the the source and header file of my class (Histogram), the executable and the LinkDef.h files. My Makefile is :[size=85]
#---------------------------------------------------
CXXFLAGS = root-config --cflags -fPIC -g
LDFLAGS = root-config --glibs
LD = g++ --std=c++11
SHARED = -shared
HDRS = Histogram.h
SRCS = Histogram.cxx HistogramsDict.cxx

CXXFILES = Histogram.cxx
OBJS = Histogram.o HistogramsDict.o

PROGRAM = Histograms.so

all: clean HistogramsDict.cxx $(PROGRAM)

HistogramsDict.cxx: Histogram.h LinkDef.h
@echo “Generating dictionary …”
@rootcint -f @ -c (CXXFLAGS) -p $^

(PROGRAM): (CXXFILES)
@echo “Linking $(PROGRAM) …”

            @/bin/rm -f $(PROGRAM)
            @$(LD) $(SHARED) -o$@ `root-config --ldflags` $(CXXFLAGS) -I$(ROOTSYS)/include $^
            @chmod 555 $(PROGRAM)
            @echo "done"

clean:; @rm -rf (OBJS) core HistogramsDict.cxx HistogramsDict.h (PROGRAM)

Histogram.o: Histogram.h

#--------------------------------------------------- [/size]

Do you have any feedback on this problem ?

Thanks a lot in advance,

Cheers,

Alvaro Lopez Solis
createPlot.cxx (2 KB)
Histogram.cxx (23.8 KB)
Histogram.h (4.15 KB)
LinkDef.h (1022 Bytes)

Try:
$(PROGRAM): $(SRCS)
@$(LD) $(CXXFLAGS) $(SHARED) -o $@ $^ $(LDFLAGS)

[quote=“Pepe Le Pew”]Try:
$(PROGRAM): $(SRCS)
@$(LD) $(CXXFLAGS) $(SHARED) -o $@ $^ $(LDFLAGS)[/quote]

Hi Pepe,

I still get the same error.

Alvaro

.
Makefile.txt (511 Bytes)
createPlot.cxx (2 KB)

Hi Pepe,

Thanks a lot !! It works

Cheers,

Alvaro