Error due to "static const int"

Hi,

     I have a class "Alpgen".  If in the .h I include these lines:

static const int Sample = 2;
static const int WhichJet = 3;
static const int WhichPhot = 3;

I get the following error.

root [0]
Processing Analysis.C…
dlopen error: /home/sushil/Wisconsin/Alpgen/Combined/./Alpgen.so: undefined symbol: _ZN6Alpgen9WhichPhotE
Load Error: Failed to load Dynamic link library /home/sushil/Wisconsin/Alpgen/Combined/./Alpgen.so

If I do not include these lines then code works fine.  One can see it  at the following link:

schauhan.web.cern.ch/schauhan/BSM/Combined/

It seems some library is needed to be load before i run my .so.

Could someone sugggest how to solve it.

Thanks and with best,
sushil

You should look in your shared libs the one containing a symbol (use nm mylib.so) looking like _ZN6Alpgen9WhichPhotE

Rene

Hi,

I did “nm Alpgen.so” and it shows me the following for the symbol “_ZN6Alpgen9WhichPhotE”




…0000ce8a T _ZN6Alpgen8LoadTreeEx
U _ZN6Alpgen8WhichJetE
U _ZN6Alpgen9WhichPhotE <---------THIS IS THE SYMBOLE
0000aa3c W ZN6AlpgenaSERKS

with best,
sushil

Hi,
As “nm Alpgen.so” says the symbol is undefined so may be the reason is that till now I was declaring Sample in my class “Alpgen” as:

static const int Sample= 2;

NOW I added one more line in my .h (outside my class definiton) file which is:

const int Alpgen::Sample; (because it is a static data member!!)

But this also gives an error as listed below:


/tmp/ccsMgafv.o(.rodata+0x0): multiple definition of Alpgen::Sample' /tmp/ccemydi0.o(.rodata+0x0): first defined here /tmp/ccsMgafv.o(.rodata+0x4): multiple definition ofAlpgen::WhichJet’
/tmp/ccemydi0.o(.rodata+0x4): first defined here
/tmp/ccsMgafv.o(.rodata+0x8): multiple definition of Alpgen::WhichPhot' /tmp/ccemydi0.o(.rodata+0x8): first defined here /tmp/ccsMgafv.o(.rodata+0xc): multiple definition ofAlpgen::NJets_upto’

with best,
sushil

[quote]NOW I added one more line in my .h (outside my class definiton) file which is:

const int Alpgen::Sample; (because it is a static data member!!) [/quote]You MUST add this line to your .cc file and NOT to your .h file. The compiler must see that line exactly once.

Cheers,
Philippe.

Thanks. It works now.

with best,
sushil