alcap-org / g4sim

Simulation toolkit based on Geant4 and ROOT
http://wuchen1106.github.io/g4sim/
2 stars 2 forks source link

Fail to compile master #15

Closed thnam closed 10 years ago

thnam commented 10 years ago

Compiling failed with this error message:

g4sim/src/MyStepLimiter.cc:42:2: error: use of undeclared identifier 'theParticleIterator'
        theParticleIterator->reset();

I suppose it relates to the stuff Chen just removed.

wuchen1106 commented 10 years ago

Hi Nam, are you sure you are working on master? and did you call "cmake ." to update Makefile? I tried to compile on my desktop and IHEP server and it worked for both cases.

thnam commented 10 years ago

Yes, I tried and failed on Mac & Linux, geant4.10.0.p2 and geant4.10.0.00 I even installed another geant4 by install-geant4.sh, but the error is still the same:

Scanning dependencies of target g4simlib
[  1%] Building CXX object CMakeFiles/g4simlib.dir/home/nam/work/g4sim/src/MyStepLimiter.cc.o
/home/nam/work/g4sim/src/MyStepLimiter.cc: In member function ‘virtual void MyStepLimiter::ConstructProcess()’:
/home/nam/work/g4sim/src/MyStepLimiter.cc:42: error: ‘theParticleIterator’ was not declared in this scope
/home/nam/work/g4sim/src/MyStepLimiter.cc:39: warning: unused variable ‘ph’
/home/nam/work/g4sim/geant4-install/include/Geant4/CLHEP/Units/PhysicalConstants.h: At global scope:
/home/nam/work/g4sim/geant4-install/include/Geant4/CLHEP/Units/PhysicalConstants.h:79: warning: ‘CLHEP::electron_charge’ defined but not used
/home/nam/work/g4sim/geant4-install/include/Geant4/CLHEP/Random/Randomize.h:61: warning: ‘CLHEP::HepRandomGenActive’ defined but not used
make[2]: *** [CMakeFiles/g4simlib.dir/home/nam/work/g4sim/src/MyStepLimiter.cc.o] Error 1
make[1]: *** [CMakeFiles/g4simlib.dir/all] Error 2
make: *** [all] Error 2
AndrewEdmonds11 commented 10 years ago

So I've just deleted my intermediate CMake files in cmake/ and tried recompiling and I get the same error as Nam. I will look into it.

benkrikler commented 10 years ago

I know that between Geant4 v9 and v10 the class G4VPhysicsConstructor stopped defining the protected field theParticleIterator so that you now need to define this object yourself in derived classes. If you guys only just upgraded to v10 then perhaps this is why you're now seeing this issue?

AndrewEdmonds11 commented 10 years ago

Yes, it could be. I'm searching through the Geant4 code on LXR site and it seems to have a lot of:

#ifdef theParticleIterator
#undef theParticleIterator
#endif

But I think I've found the class it's supposed to be:

G4ParticleTable::G4PTblDicIterator* theParticleIterator
    = G4ParticleTable::GetParticleTable()->GetIterator();

but now I'm getting linker errors...

AndrewEdmonds11 commented 10 years ago

Ok, so the linking error was because SLC5 is still on gcc4.1 and I hadn't exported the environment variables for my copy of gcc 4.7.

However, now the executable seems to be being put in g4sim/cmake/bin rather than g4sim/bin. I guess this is from when I messed around with the environment scripts yesterday so I will look into it.

AndrewEdmonds11 commented 10 years ago

And the odd location for the executable was because SLC has an old version of CMake and I hadn't added my updated version...

OK, once I've checked that g4sim works as expected I will commit and push the correction.

wuchen1106 commented 10 years ago

Thanks to Andy! This solved the problem nicely. An interesting found: they turned to use "aParticleIterator" instead of "theParticleIterator" in G4.10