Bronch not finding class

I have

[mgv4ce@node4 test]$ which root
/common/lib/root-5.34.23//bin/root

[mgv4ce@node4 test]$ which root.exe
/common/lib/root-5.34.23//bin/root.exe

I will be installing a new version of ROOT this weekend on a new machine. I will reproduce the error on that machine (or not). In the mean time of course…anything that occurs to you.

Thanks again!

Hi,

And what is your current directory fullpath name (To compare to the result of ldd).

Cheers,
Philippe.

The directory is

[mgv4ce@node4 test]$ pwd
/net/data2-4/testing/pocanic/mgv4ce/myClass/analyzer/src/test
[mgv4ce@node4 test]$ 

In your “makefile”, try to replace:
$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS)
with:
$(CXX) $(CXXFLAGS) $(SOFLAGS) $(OutPutOpt) $@ $^ $(EXPLLINKLIBS) $(LIBS)
and then try to “make clean ; make myClass.so ; make” and then try to “.L myClass.so” and TClass::GetClass(“myClass”) in “root.exe”.

That seems to have got it!

I confess that I do not understand why…in case anyone has a simple explanation.

Thank you very much!

One test, please … remove “$(LIBS)” from this line …
$(CXX) $(CXXFLAGS) $(SOFLAGS) $(OutPutOpt) $@ $^ $(EXPLLINKLIBS)
then try again “make clean ; make myClass.so ; make” and so on …

It is back!! Ack.

When I remove that line, the application can no longer find the class, and neither can interactive root. output for former is usual:

Class instance created
Error in <TTree::Bronch>: Cannot find class:myClass
Class instance destroyed

Output for latter is usual

root [0] .L myClass.so
root [1] c = TClass::GetClass("myClass")
(class TClass*)0x0
root [2] c->Print()
Error: illegal pointer to class object c 0x0 2  (tmpfile):1:
*** Interpreter error recovered ***
root [3]

And now when I put the $(LIBS) flag back in, the problem persists!

Have you done:
make clean ; make myClass.so ; make

I have indeed. For completeness here is my makefile.

#-----------configure ROOT-----------#
ifdef ROOTSYS
include $(ROOTSYS)/etc/Makefile.arch
ROOTINC     :=$(shell $(ROOTSYS)/bin/root-config --incdir)
ROOTLIBDIR  :=$(shell $(ROOTSYS)/bin/root-config --libdir)
ROOTLDFLAGS :=$(shell $(ROOTSYS)/bin/root-config --ldflags)
ROOTCFLAGS  :=$(shell $(ROOTSYS)/bin/root-config --cflags)
ROOTLIBS    := $(shell  $(ROOTSYS)/bin/root-config --libs)
ROOTLINK = $(ROOTLIBS) $(ROOTCFLAGS) $(ROOTLDFLAGS) -I$(ROOTINC)
else
@echo "NO ROOTSYS!"
endif

#--------configure compiler----------#
CXX = g++
CXXFLAGS  += $(ROOTCFLAGS)
CXXFLAGS  += -O2 -Wall -Wno-write-strings
LIBS     = $(ROOTLIBS) -lm -lz -lutil -lnsl -lpthread

.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)

#----------configure the Event class-----------#
EVENTO    = myClass.$(ObjSuf) EventDict.$(ObjSuf)
EVENTS    = myClass.$(SrcSuf) EventDict.$(SrcSuf)
EVENTSO   = myClass.$(DllSuf)
EVENTLIB  = $(shell pwd)/$(EVENTSO)

PROGRAMS= myApp

#--------object declaration----------#
OBJECTS  := $(EVENTO)
SHAREDOBJECTS = $(EVENTSO)

default: all

all: $(EVENTSO) $(PROGRAMS) 

$(EVENTSO):     $(EVENTO)
	@echo "compiling $@"
	$(CXX) $(CXXFLAGS) $(SOFLAGS) $(OutPutOpt) $@ $^ $(EXPLLINKLIBS) $(LIBS)
	@echo "$@ done"
	@echo "----------------------------------"

myClass.$(ObjSuf): myClass.h

EventDict.$(SrcSuf): myClass.h LinkDef.h
	@echo "Generating dictionary $@..."
	@rootcint -f $@ -c $^
	@echo "$@ done"
	@echo "-------------------------------"

.$(SrcSuf).$(ObjSuf):
	@echo "Compiling $@"
	$(CXX) $(CXXFLAGS) -c $<
	@echo "-----------------------------------------------------"

myApp: myApp.cxx $(EVENTSO) 
	@echo "Comiling myApp"
	$(CXX) $(CXXFLAGS) -o myApp myApp.cxx $(EVENTSO) $(LIBS)
	@echo "--"
	
clean:
	rm -f *.o *~ \#*
	@rm -f $(OBJECTS) EventDict* core
	@rm -f $(SHAREDOBJECTS) core
	rm -f $(PROGRAMS)

And the output is

[mgv4ce@node2 test]$ make clean ; make myClass.so ; make
rm -f *.o *~ \#*
rm -f myApp
g++ -O2 -Wall -fPIC -pthread -m32 -I/common/lib/root-5.34.23/include -pthread -m32 -I/common/lib/root-5.34.23/include -O2 -Wall -Wno-write-strings   -c -o myClass.o myClass.cpp
Generating dictionary EventDict.cxx...
EventDict.cxx done
-------------------------------
Compiling EventDict.o
g++ -O2 -Wall -fPIC -pthread -m32 -I/common/lib/root-5.34.23/include -pthread -m32 -I/common/lib/root-5.34.23/include -O2 -Wall -Wno-write-strings -c EventDict.cxx
-----------------------------------------------------
compiling myClass.so
g++ -O2 -Wall -fPIC -pthread -m32 -I/common/lib/root-5.34.23/include -pthread -m32 -I/common/lib/root-5.34.23/include -O2 -Wall -Wno-write-strings -shared myClass.o EventDict.o -o  myClass.so  -L/common/lib/root-5.34.23/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lm -lz -lutil -lnsl -lpthread
myClass.so done
----------------------------------
Comiling myApp
g++ -O2 -Wall -fPIC -pthread -m32 -I/common/lib/root-5.34.23/include -pthread -m32 -I/common/lib/root-5.34.23/include -O2 -Wall -Wno-write-strings -o myApp myApp.cxx myClass.so -L/common/lib/root-5.34.23/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThre

I guess it’s time for you to try the newest ROOT 5.34/36 (unless Philippe has any idea what you could try).

I should not jump straight to ROOT 6?

For ROOT 6 you need at least gcc 4.8.x (and you have gcc 4.4.7).

I can get a newer revision of gcc with no problem.

I guess you can try ROOT 6, if you like (note however, for ROOT 6, you cannot use compilers which are provided by the Red Hat Software Collections / Developer Toolset / devtoolset -> no problem for ROOT 5, though).

What OS version are you running on? Can you reupload a tar file containing your current failing example? [I.e. so far I can *not* reproduce this problem nor guess what the issue might be]

Cheers,
Philippe.

I am building new root version and trying on a different system. In the mean time, may I ask if the following files work for the experts? Or if they also have Bronch unable to find the class? This helps me narrow down where my error may be. Many thanks!
makefile.txt (1.67 KB)
LinkDef.h (150 Bytes)
myClass.cpp (404 Bytes)
myClass.h (442 Bytes)
myApp.cxx (407 Bytes)

Hi,

It did not work for me out of the box:g++ -pthread -std=c++11 -Wno-deprecated-declarations -m64 -I/home/pcanal/cint_working/rootcling/root/altc++11/include -fPIC -O2 -Wall -Wno-write-strings -shared -o myClass.so myClass.o EventDict.o -L/home/pcanal/cint_working/rootcling/root/altc++11/lib -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -pthread -lm -ldl -rdynamic -lm -lz -lutil -lnsl -lpthread -L. /home/pcanal/bin/ld: error: myClass.o: requires unsupported dynamic reloc 11; recompile with -fPIC /home/pcanal/bin/ld: error: myClass.o: requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: myClass.o: requires dynamic R_X86_64_PC32 reloc against '_ZN7myClass5ClassEv' which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: myClass.o: requires dynamic R_X86_64_PC32 reloc against '_ZN7myClass5ClassEv' which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: myClass.o: requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: myClass.o: requires dynamic R_X86_64_32 reloc against '__gxx_personality_v0' which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: EventDict.o: requires dynamic R_X86_64_PC32 reloc against '_ZN8TStorage11ObjectAllocEmPv' which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: EventDict.o: requires dynamic R_X86_64_PC32 reloc against '_ZdlPv' which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: EventDict.o: requires unsupported dynamic reloc 11; recompile with -fPIC /home/pcanal/bin/ld: error: EventDict.o: requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC /home/pcanal/bin/ld: error: EventDict.o: requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC

Once I added -fPIC ot the CXXFLAGS:CXXFLAGS += -fPIC -O2 -Wall -Wno-write-strings It worked fine for both v6 and v5 on a Scientic Linux 6.7 machine.

Cheers,
Philippe.

My operating system is:

[mgv4ce@node2 test]$ cat /etc/redhat-release
CentOS release 6.7 (Final)

[mgv4ce@node2 test]$ lsb_release -irc
Distributor ID:	CentOS
Release:	6.7
Codename:	Final

[mgv4ce@node2 test]$ uname -or
3.18.5-1.el6.elrepo.i686 GNU/Linux

Still looking into versions of ROOT.

Hi,

There is something odd with your OS installation and/or environment. I just installed CentOS 6.7 and the compilation of your example failed (as it should) mentioning that fPIC is necessary. Once I add fPIC it all works for me.

Cheers,
Philippe.