Problem linking libraries

Hello,

I have the following problem:

I installed root on ubuntu 12.04 root comiles (after a bit of trying) but when trying to compile my code I get error messages. Compiling single libraries (my own) works but when I try to compile the binary I get the following linker error message:

~/work/VubAnalysis/source/VubAnalysis_DatavsMC$ make g++ DatavsMC.cc VubAnalysis_DatavsMC.cc -I../TMVA/ -Wall -w -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -pthread -m64 -I/home/thomas/work/computing/root/include -L../../lib/ -L../TMVA/lib/ -lTMVA.1 -L/home/thomas/work/computing/root/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic -lPidTables -lTXslFFReweighting -lMLP -lXMLIO -lTreePlayer -lMinuit -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -g -o ../../bin/DatavsMC_test /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TGaxis::TGaxis(double, double, double, double, double, double, int, char const*, double)' /home/thomas/work/computing/root/lib/libMLP.so: undefined reference to `TMarker::TMarker(double, double, int)' ../../lib//libPidTables.so: undefined reference to `TLatex::TLatex(double, double, char const*)' ../../lib//libPidTables.so: undefined reference to `TLatex::GetXsize()' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_D2()' /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TPolyMarker3D::SetPoint(int, double, double, double)' ../../lib//libPidTables.so: undefined reference to `TCanvas::TCanvas(char const*, char const*, int, int)' /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TPolyMarker3D::TPolyMarker3D(int, short, char const*)' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDlnu_CLN::~XSLBToDlnu_CLN()' ../../lib//libVubReweighter.so: undefined reference to `XSLPseudoScalarFF::FromISGW2ToThisModel()' ../../lib//libPidTables.so: undefined reference to `TPad::TPad(char const*, char const*, double, double, double, double, short, short, short)' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDstrlnu_DstrToDpi_CLN::FromSP8ToThisModel()' ../../lib//libPidTables.so: undefined reference to `TBox::TBox(double, double, double, double)' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::~XSLBToDSSlnu_LLSW_m2()' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::XSLBToDSSlnu_LLSW_m2(double, double, double, double, int, double, int, bool)' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_D1prime()' ../../lib//libPidTables.so: undefined reference to `TBox::~TBox()' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_D1()' ../../lib//libPidTables.so: undefined reference to `TLegend::TLegend(double, double, double, double, char const*, char const*)' /home/thomas/work/computing/root/lib/libMLP.so: undefined reference to `TCanvas::TCanvas(char const*, char const*, int)' ../../lib//libPidTables.so: undefined reference to `TLegend::AddEntry(TObject const*, char const*, char const*)' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDlnu_CLN::XSLBToDlnu_CLN(double, double, double, double, double, double)' ../../lib//libPidTables.so: undefined reference to `TLine::TLine(double, double, double, double)' /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TPolyMarker3D::TPolyMarker3D()' /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TPaveText::TPaveText(double, double, double, double, char const*)' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDstrlnu_DstrToDpi_CLN::~XSLBToDstrlnu_DstrToDpi_CLN()' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDstrlnu_DstrToDpi_CLN::XSLBToDstrlnu_DstrToDpi_CLN(double, double, double, double, double, double, double, double, double)' ../../lib//libVubReweighter.so: undefined reference to `XSLKin::XSLKin(TLorentzVector, TLorentzVector, TLorentzVector, TLorentzVector)' /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TView::CreateView(int, double const*, double const*)' ../../lib//libPidTables.so: undefined reference to `TLatex::~TLatex()' ../../lib//libPidTables.so: undefined reference to `TBox::TBox()' /home/thomas/work/computing/root/lib/libMLP.so: undefined reference to `TText::TText(double, double, char const*)' /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TText::Paint(char const*)' ../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_Dss0()' /home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TText::~TText()' ../../lib//libVubReweighter.so: undefined reference to `XSLKin::XSLKin(TLorentzVector, TLorentzVector, TLorentzVector)' collect2: ld returned 1 exit status make: *** [all] Error 1
Each of the libraries mentioned in the above error message compiled fine.

The code compiled fine on other systems. I tried both root 5.28h and 5.30. Both time the same issue.

I compiled root with that command (the default did not work):

./configure linuxx8664gcc --with-x11-libdir=/usr/lib/x86_64-linux-gnu/ --with-xpm-libdir=/usr/lib/x86_64-linux-gnu/ --with-xft-libdir=/usr/lib/x86_64-linux-gnu/ --with-xext-libdir=/usr/lib/x86_64-linux-gnu/ --enable-minuit2 --disable-xrootd

make -j2 LDFLAGS="-Wl,--no-as-needed"

My compiler version is:

g++ --version 
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.

I also exported the nessesary pathes:

export ROOTSYS=/home/thomas/work/computing/root/
export PATH=/home/thomas/work/VubAnalysis/bin/:$ROOTSYS/bin/:$PATH
export LD_LIBRARY_PATH=/home/thomas/work/VubAnalysis/lib/:$ROOTSYS/lib/:$LD_LIBRARY_PATH

Has anybody an idea what I could have done wrong?

Thanks,
Thomas

Try: `root-config --cxx --cflags` -I../TMVA/ -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/ -L../TMVA/lib/ -lTMVA.1 -lPidTables -lTXslFFReweighting -lMLP -lXMLIO -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter `root-config --glibs` -lMinuit

Hi,

I tried that and the error message changed to:

g++ -pthread -m64 -I/home/thomas/work/computing/root/include -I../TMVA/ -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/  -L../TMVA/lib/ -lTMVA.1 -lPidTables -lTXslFFReweighting -lMLP -lXMLIO -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -L/home/thomas/work/computing/root/lib -lGui -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic -lMinuit
In file included from VubAnalysis_DatavsMC.cc:9:0:
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:64:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:67:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:70:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
In file included from ../PidTables/TObjTable.hh:13:0,
                 from ../PidTables/TPidTable.hh:7,
                 from ../PidTables/TSystPidTable.hh:4,
                 from VubAnalysis_DatavsMC.cc:29:
../PidTables/TCell.hh:35:18: warning: unused parameter ‘other’ [-Wunused-parameter]
../PidTables/TCell.hh:36:18: warning: unused parameter ‘other’ [-Wunused-parameter]
../PidTables/TCell.hh:39:18: warning: unused parameter ‘list’ [-Wunused-parameter]
../PidTables/TCell.hh:40:18: warning: unused parameter ‘other’ [-Wunused-parameter]
In file included from ../PidTables/TPidTable.hh:8:0,
                 from ../PidTables/TSystPidTable.hh:4,
                 from VubAnalysis_DatavsMC.cc:29:
../PidTables/TPidData.hh:61:16: warning: unused parameter ‘o’ [-Wunused-parameter]
VubAnalysis_DatavsMC.cc: In member function ‘void VubAnalysis_DatavsMC::LoopOneMode(TChain*, DataTypes::Mode, double, Runs::run)’:
VubAnalysis_DatavsMC.cc:601:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:925:59: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:959:62: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:1193:11: warning: unused variable ‘isgood’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:1185:12: warning: unused variable ‘thetacms’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:370:7: warning: unused variable ‘npi0cutted’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc: In member function ‘void VubAnalysis_DatavsMC::InitDataTypeHist(DataTypes::Mode)’:
VubAnalysis_DatavsMC.cc:1766:10: warning: unused variable ‘vtxmin’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:1767:10: warning: unused variable ‘vtxmax’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc: In member function ‘int VubAnalysis_DatavsMC::GetDMother()’:
VubAnalysis_DatavsMC.cc:2060:17: warning: variable ‘lepInd’ set but not used [-Wunused-but-set-variable]
VubAnalysis_DatavsMC.cc:2060:29: warning: unused variable ‘nuInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2060:40: warning: unused variable ‘xInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2060:50: warning: unused variable ‘xdauInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:8: warning: unused variable ‘foundNu’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:24: warning: unused variable ‘foundX’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:39: warning: unused variable ‘XisDstar’ [-Wunused-variable]
../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_D2()'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDlnu_CLN::~XSLBToDlnu_CLN()'
../../lib//libVubReweighter.so: undefined reference to `XSLPseudoScalarFF::FromISGW2ToThisModel()'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDstrlnu_DstrToDpi_CLN::FromSP8ToThisModel()'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::~XSLBToDSSlnu_LLSW_m2()'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::XSLBToDSSlnu_LLSW_m2(double, double, double, double, int, double, int, bool)'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_D1prime()'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_D1()'
../TMVA/lib//libTMVA.1.so: undefined reference to `TTreeFormula::TTreeFormula(char const*, char const*, TTree*)'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDlnu_CLN::XSLBToDlnu_CLN(double, double, double, double, double, double)'
/home/thomas/work/computing/root/lib/libMLP.so: undefined reference to `TTreeFormulaManager::TTreeFormulaManager()'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDstrlnu_DstrToDpi_CLN::~XSLBToDstrlnu_DstrToDpi_CLN()'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDstrlnu_DstrToDpi_CLN::XSLBToDstrlnu_DstrToDpi_CLN(double, double, double, double, double, double, double, double, double)'
../../lib//libVubReweighter.so: undefined reference to `XSLKin::XSLKin(TLorentzVector, TLorentzVector, TLorentzVector, TLorentzVector)'
../../lib//libVubReweighter.so: undefined reference to `XSLBToDSSlnu_LLSW_m2::FromISGW2ToThisModel_Dss0()'
../../lib//libVubReweighter.so: undefined reference to `XSLKin::XSLKin(TLorentzVector, TLorentzVector, TLorentzVector)'
collect2: ld returned 1 exit status

Since most of the linking errors are caused by the VubReweighter (my implementation) package
it might be a problem how I compile the shared libraries!?
Below I posted the makefile for that library.

## GNUmakefile for my small rescale analysis of ccbar and uds underground. ##

PACKAGE = VubReweighter

## Compiler and flags.
CXX = g++ 
CXXFLAGS      = -Wall -w -fPIC -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -I. 
LIBFLAGS      = -shared 



# ROOT stuff
ROOTCFLAGS    = $(shell $(ROOTSYS)/bin/root-config --cflags)
ROOTLIBS      = $(shell $(ROOTSYS)/bin/root-config --libs)
ROOTGLIBS     = $(shell $(ROOTSYS)/bin/root-config --glibs)
ROOTLDFLAGS   = $(shell $(ROOTSYS)/bin/root-config --ldflags)

CXXFLAGS     += $(ROOTCFLAGS)

# Debug flag
DXXFLAGS     += $(CXXFLAGS) -g

# 



OBJ = ../../obj/
BIN = ../../bin/
LIB = ../../lib/


# Targets

lib:
	$(CXX) $(CXXFLAGS) -c MCReweighter.cc -o $(OBJ)MCReweighter.o
	$(CXX) $(CXXFLAGS) -c SlowPiReweighter.cc -o $(OBJ)SlowPiReweighter.o
	$(CXX) $(CXXFLAGS) -c DecayReweighter.cc -o $(OBJ)DecayReweighter.o
	$(CXX) $(CXXFLAGS) -c FinalState.cc -o $(OBJ)FinalState.o
	rootcint -f VubReweighterDict.cxx -c -I../ FinalState.hh DecayReweighter.hh MCReweighter.hh SlowPiReweighter.hh VubReweighterLinkDef.hh 
	$(CXX) $(CXXFLAGS) -c VubReweighterDict.cxx -o  $(OBJ)VubReweighterDict.o
	$(CXX) -shared $(ROOTGLIBS) $(ROOTLDFLAGS) -L../../lib/ -lVubAnalysis_Base -lVubHybrid -lTXslFFReweighting $(OBJ)FinalState.o $(OBJ)DecayReweighter.o $(OBJ)MCReweighter.o $(OBJ)SlowPiReweighter.o  $(OBJ)VubReweighterDict.o -o $(LIB)libVubReweighter.so





hello:
	echo "hello"	

clean:
	echo ""
	rm -f $(OBJ)*.o \
  rm -f $(LIB)libVubReweighter.so \
  rm -f VubReweighterDict.cxx

Second iteration: `root-config --cxx --cflags` -I../TMVA/ -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/ -L../TMVA/lib/ -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -lTMVA.1 -lPidTables -lTXslFFReweighting -lMLP -lXMLIO `root-config --glibs` -lMinuit

I think we are getting closer. now it has only a problem with the TMVA lib:

g++ -pthread -m64 -I/home/thomas/work/computing/root/include -I../TMVA/ -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/  -L../TMVA/lib/ -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -lTMVA.1 -lPidTables -lTXslFFReweighting -lMLP -lXMLIO -L/home/thomas/work/computing/root/lib -lGui -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic -lMinuit
In file included from VubAnalysis_DatavsMC.cc:9:0:
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:64:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:67:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:70:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
In file included from ../PidTables/TObjTable.hh:13:0,
                 from ../PidTables/TPidTable.hh:7,
                 from ../PidTables/TSystPidTable.hh:4,
                 from VubAnalysis_DatavsMC.cc:29:
../PidTables/TCell.hh:35:18: warning: unused parameter ‘other’ [-Wunused-parameter]
../PidTables/TCell.hh:36:18: warning: unused parameter ‘other’ [-Wunused-parameter]
../PidTables/TCell.hh:39:18: warning: unused parameter ‘list’ [-Wunused-parameter]
../PidTables/TCell.hh:40:18: warning: unused parameter ‘other’ [-Wunused-parameter]
In file included from ../PidTables/TPidTable.hh:8:0,
                 from ../PidTables/TSystPidTable.hh:4,
                 from VubAnalysis_DatavsMC.cc:29:
../PidTables/TPidData.hh:61:16: warning: unused parameter ‘o’ [-Wunused-parameter]
VubAnalysis_DatavsMC.cc: In member function ‘void VubAnalysis_DatavsMC::LoopOneMode(TChain*, DataTypes::Mode, double, Runs::run)’:
VubAnalysis_DatavsMC.cc:601:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:925:59: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:959:62: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:1193:11: warning: unused variable ‘isgood’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:1185:12: warning: unused variable ‘thetacms’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:370:7: warning: unused variable ‘npi0cutted’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc: In member function ‘void VubAnalysis_DatavsMC::InitDataTypeHist(DataTypes::Mode)’:
VubAnalysis_DatavsMC.cc:1766:10: warning: unused variable ‘vtxmin’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:1767:10: warning: unused variable ‘vtxmax’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc: In member function ‘int VubAnalysis_DatavsMC::GetDMother()’:
VubAnalysis_DatavsMC.cc:2060:17: warning: variable ‘lepInd’ set but not used [-Wunused-but-set-variable]
VubAnalysis_DatavsMC.cc:2060:29: warning: unused variable ‘nuInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2060:40: warning: unused variable ‘xInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2060:50: warning: unused variable ‘xdauInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:8: warning: unused variable ‘foundNu’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:24: warning: unused variable ‘foundX’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:39: warning: unused variable ‘XisDstar’ [-Wunused-variable]
../TMVA/lib//libTMVA.1.so: undefined reference to `TTreeFormula::TTreeFormula(char const*, char const*, TTree*)'
/home/thomas/work/computing/root/lib/libMLP.so: undefined reference to `TTreeFormulaManager::TTreeFormulaManager()'
collect2: ld returned 1 exit status

The TMVA lib I am including is just a link to the one in root:

> ll ../TMVA/
lib/
TMVA -> ../../../computing/root/tmva/inc//

> ll ../TMVA/lib/
libTMVA.1.rootmap -> ../../../../computing/root/lib/libTMVA.rootmap
libTMVA.1.so -> ../../../../computing/root/lib/libTMVA.so*

Third iteration: try to add “-lTreePlayer” in the end of the command line, right after or before “-lMinuit”.

Actually, if TMVA, MLP, XMLIO come from ROOT, you should try something like this: `root-config --cxx --cflags` -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/ -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -lPidTables -lTXslFFReweighting `root-config --glibs` -lTMVA -lMLP -lXMLIO -lTreePlayer -lMinuit

Hi,

I tried both positions (before and after Minuit) but it didnt do the trick. Now it is missing the PolyMarker3D. Shouldnt this one be in Graf3d?

g++ -pthread -m64 -I/home/thomas/work/computing/root/include -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/ -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -lPidTables -lTXslFFReweighting -L/home/thomas/work/computing/root/lib -lGui -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic -lTMVA -lMLP -lXMLIO  -lMinuit -lTreePlayer
In file included from VubAnalysis_DatavsMC.cc:9:0:
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:64:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:67:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
../XslFFReweighting/XSLBToDstrlnu_DstrToDpi_CLN.hh:70:17: warning: unused parameter ‘chi’ [-Wunused-parameter]
In file included from ../PidTables/TObjTable.hh:13:0,
                 from ../PidTables/TPidTable.hh:7,
                 from ../PidTables/TSystPidTable.hh:4,
                 from VubAnalysis_DatavsMC.cc:29:
../PidTables/TCell.hh:35:18: warning: unused parameter ‘other’ [-Wunused-parameter]
../PidTables/TCell.hh:36:18: warning: unused parameter ‘other’ [-Wunused-parameter]
../PidTables/TCell.hh:39:18: warning: unused parameter ‘list’ [-Wunused-parameter]
../PidTables/TCell.hh:40:18: warning: unused parameter ‘other’ [-Wunused-parameter]
In file included from ../PidTables/TPidTable.hh:8:0,
                 from ../PidTables/TSystPidTable.hh:4,
                 from VubAnalysis_DatavsMC.cc:29:
../PidTables/TPidData.hh:61:16: warning: unused parameter ‘o’ [-Wunused-parameter]
VubAnalysis_DatavsMC.cc: In member function ‘void VubAnalysis_DatavsMC::LoopOneMode(TChain*, DataTypes::Mode, double, Runs::run)’:
VubAnalysis_DatavsMC.cc:601:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:925:59: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:959:62: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
VubAnalysis_DatavsMC.cc:1193:11: warning: unused variable ‘isgood’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:1185:12: warning: unused variable ‘thetacms’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:370:7: warning: unused variable ‘npi0cutted’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc: In member function ‘void VubAnalysis_DatavsMC::InitDataTypeHist(DataTypes::Mode)’:
VubAnalysis_DatavsMC.cc:1766:10: warning: unused variable ‘vtxmin’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:1767:10: warning: unused variable ‘vtxmax’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc: In member function ‘int VubAnalysis_DatavsMC::GetDMother()’:
VubAnalysis_DatavsMC.cc:2060:17: warning: variable ‘lepInd’ set but not used [-Wunused-but-set-variable]
VubAnalysis_DatavsMC.cc:2060:29: warning: unused variable ‘nuInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2060:40: warning: unused variable ‘xInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2060:50: warning: unused variable ‘xdauInd’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:8: warning: unused variable ‘foundNu’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:24: warning: unused variable ‘foundX’ [-Wunused-variable]
VubAnalysis_DatavsMC.cc:2061:39: warning: unused variable ‘XisDstar’ [-Wunused-variable]
/home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TPolyMarker3D::SetPoint(int, double, double, double)'
/home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TPolyMarker3D::TPolyMarker3D(int, short, char const*)'
/home/thomas/work/computing/root/lib/libTreePlayer.so: undefined reference to `TPolyMarker3D::TPolyMarker3D()'
collect2: ld returned 1 exit status

I believe this should work: `root-config --cxx --cflags` -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/ -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -lPidTables -lTXslFFReweighting `root-config --libs` -lTMVA -lMinuit -lXMLIO -lMLP -lTreePlayer
If not, try to make ROOT’s “test” examples. One of them is the “stressTMVA”, so while making it, you will see all required flags (which may somehow differ from what I show above even if I’ve just copied the order of ROOT’s libraries from the “./test/Makefile” -> maybe you will get some additional linker flags).

I’ve got an additional idea … try to add “-Wl,–no-as-needed” right before "-L…/…/lib/ "

Your compiler command did not work. But I followed your suggestion and made that test thingy. It has the following lib included:

-L/home/thomas/work/computing/root/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic  -lTMVA -lMinuit -lXMLIO -lMLP -lTreePlayer

I simply copied all of them behind the original compiler command:

g++ -pthread -m64 -I/home/thomas/work/computing/root/include -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc -L../../lib/ -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -lPidTables -lTXslFFReweighting -L/home/thomas/work/computing/root/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic -lTMVA -lMinuit -lXMLIO -lMLP -lTreePlayer -L/home/thomas/work/computing/root/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic  -lTMVA -lMinuit -lXMLIO -lMLP -lTreePlayer

And it compiled :slight_smile:

But since all of the libs I added have been already in the previous linker command I assume that it has to do something with the order they have to be linked.

Your last suggestion also worked:

g++ -pthread -m64 -I/home/thomas/work/computing/root/include -W -Wall -O0 -DBABAR_COMP_INST -fno-exceptions -fPIC -I.. -g -o ../../bin/DatavsMC_test DatavsMC.cc VubAnalysis_DatavsMC.cc "-Wl,--no-as-needed" -L../../lib/ -lVubAnalysis_Base -lVubHybrid -lVubReweighter -lVubCutter -lPidTables -lTXslFFReweighting -L/home/thomas/work/computing/root/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl -rdynamic -lTMVA -lMinuit -lXMLIO -lMLP -lTreePlayer

Anyways many thanks to you , You helped me very much.

PS: how do I mark this thread as solved?

I don’t get it now … do you say that the “stressTMVA” example did not contain the “-Wl,–no-as-needed” flag when linking?
Then I don’t understand why your application needs this flag.
Maybe there was another “magic” flag which did this trick for “stressTMVA”? And if yes, you should use this flag, too.

BTW. I don’t think that “doubling” the list of libraries is a good idea (i.e. add the “-Wl,–no-as-needed” if required).

P.S. There should be a small green button “/” (called “Accept this answer” next to “EDIT”) which makes the thread “SOLVED”.

No it did not contain that flag. But the stressTMVA also did not compile in the first place. I just checked it compiles if I put the flag ("-Wl,–no-as-needed") in.

I think you are right with the “doubling” the libs. For the future I will use that flag.

What does that flag do?

Search for “–no-as-needed” in:
man ld

Ok thanks again.

Cheers,
Thomas