ClassImp problem with Mac OS X Tiger

Hi!

First of all. I didn’t had the problems described below on Linux with gcc3.

I made a few objects similar to the ROOT test example Event.h, Event.cc with the corresponding Makefile. May I have circular dependencies however they didn’t hurt for Linux with gcc3.

Now I have and Intel based Mac and tried to compile my project on this platform with gcc4. I adopted the changed options dynlib stuff etc. carefully.

I can compile each object. I think a dictionary (with verbosity v4) named T…Dict.h and T…Dict.cc was made successfully but the compilation fails with:
error: redefinition of ‘int ROOT::R__dummyintdefault5’

I can provide more info if needed.

Help is very appreciated!

Regards, Arno

[arnobook] ~/HbbAnalyse make c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c TJetLifetime.cxx c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c T4tag.cxx c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c THJetTagPerformance.cxx c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c THFlavour.cxx c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c THFlavour2D.cxx c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c TFit.cxx c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c THWeight.cxx c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c TCMSTreeReader.cxx Generating dictionary TCMSTreeReaderDict ... Note: File "TJetLifetime.h" already loaded Note: File "T4tag.h" already loaded Note: File "THJetTagPerformance.h" already loaded Note: File "THFlavour.h" already loaded Note: File "THFlavour2D.h" already loaded Note: File "TFit.h" already loaded Note: File "THWeight.h" already loaded Note: File "TCMSTreeReader.h" already loaded ... dictionary of TCMSTreeReaderDict done. c++ -O2 -pipe -Wall -W -Woverloaded-virtual -DAC1Root_standalone -D_REENTRANT -Wno-long-double -I/ROOT/v5.10.00/include -c TCMSTreeReaderDict.cxx T4tag.cxx:5: error: redefinition of 'int ROOT::R__dummyintdefault5' TJetLifetime.cxx:5: error: 'int ROOT::R__dummyintdefault5' previously declared here T4tag.cxx:5: error: redefinition of 'class ROOT::R__dummyintdefault5_c' TJetLifetime.cxx:5: error: previous definition of 'class ROOT::R__dummyintdefault5_c' T4tag.cxx:7: warning: unused parameter 'TagFileName' T4tag.cxx:7: warning: unused parameter 'TagFileName' THJetTagPerformance.cxx:5: error: redefinition of 'int ROOT::R__dummyintdefault5' TJetLifetime.cxx:5: error: 'int ROOT::R__dummyintdefault5' previously declared here THJetTagPerformance.cxx:5: error: redefinition of 'class ROOT::R__dummyintdefault5_c' TJetLifetime.cxx:5: error: previous definition of 'class ROOT::R__dummyintdefault5_c' THFlavour.cxx:5: error: redefinition of 'int ROOT::R__dummyintdefault5' TJetLifetime.cxx:5: error: 'int ROOT::R__dummyintdefault5' previously declared here THFlavour.cxx:5: error: redefinition of 'class ROOT::R__dummyintdefault5_c' TJetLifetime.cxx:5: error: previous definition of 'class ROOT::R__dummyintdefault5_c' THFlavour2D.cxx:5: error: redefinition of 'int ROOT::R__dummyintdefault5' TJetLifetime.cxx:5: error: 'int ROOT::R__dummyintdefault5' previously declared here THFlavour2D.cxx:5: error: redefinition of 'class ROOT::R__dummyintdefault5_c' TJetLifetime.cxx:5: error: previous definition of 'class ROOT::R__dummyintdefault5_c' TFit.cxx:5: error: redefinition of 'int ROOT::R__dummyintdefault5' TJetLifetime.cxx:5: error: 'int ROOT::R__dummyintdefault5' previously declared here TFit.cxx:5: error: redefinition of 'class ROOT::R__dummyintdefault5_c' TJetLifetime.cxx:5: error: previous definition of 'class ROOT::R__dummyintdefault5_c' THWeight.cxx:5: error: redefinition of 'int ROOT::R__dummyintdefault5' TJetLifetime.cxx:5: error: 'int ROOT::R__dummyintdefault5' previously declared here THWeight.cxx:5: error: redefinition of 'class ROOT::R__dummyintdefault5_c' TJetLifetime.cxx:5: error: previous definition of 'class ROOT::R__dummyintdefault5_c' TCMSTreeReader.cxx:5: error: redefinition of 'int ROOT::R__dummyintdefault5' TJetLifetime.cxx:5: error: 'int ROOT::R__dummyintdefault5' previously declared here TCMSTreeReader.cxx:5: error: redefinition of 'class ROOT::R__dummyintdefault5_c' TJetLifetime.cxx:5: error: previous definition of 'class ROOT::R__dummyintdefault5_c' make: *** [TCMSTreeReaderDict.o] Error 1 [arnobook] ~/HbbAnalyse
TCMSTreeReaderLinkDef.h (419 Bytes)

Most likely you pass the .cxx files as argument to rootcint. It only needs the .h files.

In addition, you may want to use the newer ROOT I/O implementation (simply add a + at the end of the class name in the link directive:

Cheers,
Philippe

Hi,

you’re including all your sources into one, to get a library using Aclic, right? Just remove all ClassImp invocations; you don’t need them.

Axel.

Hi!

Thanks for the suggestions. Using only the .h files solves my problem. I added also the + for the new I/O mechanism.

Sometimes I want to use aclic mostly I compile the libraries outside a ROOT session …

Because of that I have another question. All the ClassImp statements in my .cc files are surrounded by e.g.:

#if !defined(CINT) || defined(MAKECINT)
ClassImp(TCMSTreeReader);
#endif

Why are these switches not working/useless? Due to gcc4, Mac OS X … ?!

Best, Arno

They work fine … they purpose is to hide the ClassImp when trying to use the source file in interpreted mode (as opposed to dictionary generation or compilation).

Cheers,
Philippe.

Ok I understand. But why these problems didn’t occur as I did it wrongly in Linux !? I would like to understand it more deeply cause I need more software to run on Intel based Macs.

Thanks, Arno

The issue is that ClassImp defines a variable that is unique named based on the line number. Hence it should lead to the error message you saw each time you include 2 sources file in the same file. So the problem should be the same on linux or macos (as long as you do the same thing).

Cheers,
Philippe.

PS. As noted by Axel, ClassImp is actually optional, if you do not need to produce documentation using THtml, you do not need it (and even that requirement will be lifted soon)

Hi again!

I used exactly the same code, but I had to modify the Makefile to make the .dynlib things etc.

Anyhow I am happy that it finally works.

Thanks again, Arno