Errors comping against ROOT on Ubuntu 14.04.4

Hi guys,

There seems to be some difficulty compiling against ROOT on Ubuntu 14.04.4 (kernel 3.13.0-79-generic on 64 bit machine). The root version is 5.34/36 and gcc is 4.8.4. Using the same version of root on CentOS (gcc of 4.8.5-4), there are no errors. I get the following on Ubuntu (which is where we’d like to do our analysis):

(sorry for the large mess here).

make SortDGS
g++ -O -Wall -fPIC -pthread -m64 -I/usr/local/include/root -L/usr/local/lib/root -lNew -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lm SortDGS.cc -o …/bin/SortDGS
SortDGS.cc: In function ‘int main(int, char**)’:
SortDGS.cc:223:26: warning: variable ‘tsLast’ set but not used [-Wunused-but-set-variable]
unsigned long long int tsLast=0;
^
In file included from SortDGS.cc:49:0:
DGSDecomp.cc: In function ‘unsigned int* GetEvBuf(FILE*, const char*, GEBheader*)’:
DGSDecomp.cc:18:38: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
fread(EventBuf,Header->length,1,fp);
^
/tmp/ccogTKSb.o: In function setuproot(TFile*)': SortDGS.cc:(.text+0x182f): undefined reference toTStorage::ObjectAlloc(unsigned long)'
SortDGS.cc:(.text+0x186c): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' SortDGS.cc:(.text+0x18ce): undefined reference toTStorage::ObjectAlloc(unsigned long)'
SortDGS.cc:(.text+0x190b): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' SortDGS.cc:(.text+0x196d): undefined reference toTStorage::ObjectAlloc(unsigned long)'
SortDGS.cc:(.text+0x19aa): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' SortDGS.cc:(.text+0x19f2): undefined reference toTStorage::ObjectAlloc(unsigned long)'
SortDGS.cc:(.text+0x1a27): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' SortDGS.cc:(.text+0x1a6f): undefined reference toTStorage::ObjectAlloc(unsigned long)'
SortDGS.cc:(.text+0x1aa4): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' SortDGS.cc:(.text+0x1af9): undefined reference toTStorage::ObjectAlloc(unsigned long)'
SortDGS.cc:(.text+0x1b3a): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' SortDGS.cc:(.text+0x1b86): undefined reference toTStorage::ObjectAlloc(unsigned long)'
SortDGS.cc:(.text+0x1bc7): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' SortDGS.cc:(.text+0x1be1): undefined reference toTObject::operator delete(void*)‘
SortDGS.cc:(.text+0x1bf4): undefined reference to TObject::operator delete(void*)' SortDGS.cc:(.text+0x1c07): undefined reference toTObject::operator delete(void*)‘
SortDGS.cc:(.text+0x1c1a): undefined reference to TObject::operator delete(void*)' SortDGS.cc:(.text+0x1c2d): undefined reference toTObject::operator delete(void*)’
/tmp/ccogTKSb.o:SortDGS.cc:(.text+0x1c40): more undefined references to TObject::operator delete(void*)' follow /tmp/ccogTKSb.o: In functionmain’:
SortDGS.cc:(.text+0x2ce0): undefined reference to TStorage::ObjectAlloc(unsigned long)' SortDGS.cc:(.text+0x2d03): undefined reference toTFile::TFile(char const*, char const*, char const*, int)‘
SortDGS.cc:(.text+0x2f09): undefined reference to TObject::operator delete(void*)' /tmp/ccogTKSb.o: In function_GLOBAL__sub_I_SortDGS.cc’:
SortDGS.cc:(.text+0x2f4c): undefined reference to `TVersionCheck::TVersionCheck(int)'
collect2: error: ld returned 1 exit status
make: *** [SortDGS] Error 1


The make file I was given is as follows:

ROOTINC = $(shell root-config --cflags)
ROOTLIB = $(shell root-config --new --libs)

BIN     = ../bin
CC      =  g++
CCFLAG   = -O -Wall -fPIC

SortDGS:        SortDGS.cc DGSCHICO.h DGSDecomp.cc InitBase.cc BinDGS.cc
                $(CC) $(CCFLAG) $(ROOTINC) $(ROOTLIB) $(CCENV) -lm $< -o $(BIN)/$@

I don’t see anything obviously wrong with this. Also the 2 shell commands at the beginning give what I’d expect. For example, the include directory does have TH2F.h (and going back to TH2.h), the constructor for which make is complaining about, is there and seems to have the constructor in question. The lib directory goes back to /usr/local/lib/root and everything seems to be o.k. there. I can supply the source codes I’m trying to compile if anybody wants to try it, but hopefully, it’s just something silly in the Makefile we’re all missing here.

Thanks,
Tim

$(CC) $(CCFLAG) $(ROOTINC) $(CCENV) $< -o $(BIN)/$@ $(ROOTLIB)

Hi Pepe,

Thank you so much! That fixed it.

cheers,
Tim