Compiling with geant4 and own libraries

I am having a new problem when compiling some of my code. I get the following:

/usr/local/root/include/TGeoElement.h:139: error: expected unqualified-id before ‘)’ token
while compiling the last bit of my code, just before linking. I am stumped. I have tried different versions of root and geant4 with no success. The only difference is the line number in TGeoElement.h due to different versions, but is always the line which reads

Double_t Status() const {return fStatus;}
This very well could be unrelated to ROOT. I have been looking for #define’s that could be doing this… Thats the last of my ideas.
I can compile my code with ROOT into a standalone program without Geant4 libraries.

I am hoping that this also has to do with my inability to compile geant4_vmc which gives me the following compilation errors:

Generating /usr/local/geant4_vmc/source/../tmp/tgt_linux/geant4Cint.cxx Making includes ... #error "You need a ISO C conforming compiler to use the glibc headers" Error: Missing one of ' \/' expected at or after line 89. Error: Unexpected end of file (G__fgetstream():2) /usr/include/sys/cdefs.h:349: Error: Symbol extern"C"{ # define __need_size_t # define __need_NULL # include<stddef is not defined in current scope /usr/include/stdio.h:45: Error: Failed to evaluate extern"C"{ # define __need_size_t # define __need_NULL # include<stddef.h> # include<bits/types Error: Failed to evaluate extern"C"{ # define __need_size_t # define __need_NULL # include<stddef.h> # include<bits/types.h> # define __need_FILE # define __need___FILE #endif #if !defined __FILE_defined&& defined __need_FILE struct _IO_FILE Error: Symbol __BEGIN_NAMESPACE_STDtypedefstruct_IO_FILEFILE is not defined in current scope /usr/include/stdio.h:49: Error: Missing one of '{' expected at or after line 91. Error: Unexpected end of file (G__fignorestream():3) /usr/include/stdio.h:853: Error: Missing one of '{' expected at or after line 40. Error: Unexpected end of file (G__fignorestream():3) /usr/include/string.h:435: Warning: Error occurred during reading source files Warning: Error occurred during dictionary source generation !!!Removing /usr/local/geant4_vmc/source/../tmp/tgt_linux/geant4Cint.cxx /usr/local/geant4_vmc/source/../tmp/tgt_linux/geant4Cint.h !!! Error: rootcint: error loading headers... make: *** [/usr/local/geant4_vmc/source/../tmp/tgt_linux/geant4Cint.cxx] Error 1 make: *** Waiting for unfinished jobs....

Thanks in advance!

Hi,

We will need more information to understand what happens;
could you, please, let us know you platform and compiler version
with which you got the error reported.

Also, could you give the version of Geant4 and Root with which you
get the compiling error from TGeoElement (it is important to know
the line number together with the version of Root which you use.)

And, as the error happens when compiling your own program, could
you give us all the compiler options and include paths which you use
to build your program.

Best regards,

I am using geant4.9.3.p02, root 5.27/06a, vgm 3.03 on Ubuntu 7.10. with gcc version 4.1.3.

I have narrowed the problem down to VGM. If i comment out the code, headers and linking flags for VGM then it compiles.

While compiling VGM there is a lot of the following after running ‘make check’ :

/usr/local/geant4.9.3.p02/lib/Linux-g++/libG4OpenInventor.so: undefined reference to `G4VInteractorManager::AddDispatcher(bool (*)(void*))' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4event.so: undefined reference to `G4VCellScorerStore::G4VCellScorerStore()' ../packages/Geant4GM/.libs/libGeant4GM.so: undefined reference to `typeinfo for G4Hype' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4error_propagation.so: undefined reference to `G4PionPlus::PionPlusDefinition()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG3toG4.so: undefined reference to `gsvolu_' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4OpenGL.so: undefined reference to `G4Xt::PutStringInResourceDatabase(char*)' ../packages/Geant4GM/.libs/libGeant4GM.so: undefined reference to `G4TessellatedSolid::GetFacet(unsigned int) const' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4event.so: undefined reference to `G4Electron::Definition()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4event.so: undefined reference to `G4PrimaryVertex::~G4PrimaryVertex()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4error_propagation.so: undefined reference to `typeinfo for G4ErrorTarget' ../packages/Geant4GM/.libs/libGeant4GM.so: undefined reference to `G4ReflectionFactory::Divide(G4String const&, G4LogicalVolume*, G4LogicalVolume*, EAxis, int, double, double)' ../packages/Geant4GM/.libs/libGeant4GM.so: undefined reference to `typeinfo for G4Para' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4GMocren.so: undefined reference to `vtable for G4CSGSolid' ../packages/Geant4GM/.libs/libGeant4GM.so: undefined reference to `typeinfo for G4Cons' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4GMocren.so: undefined reference to `typeinfo for G4VPVParameterisation' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4materials.so: undefined reference to `G4PhysicsLinearVector::G4PhysicsLinearVector()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4event.so: undefined reference to `anHCoTHAllocator' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4event.so: undefined reference to `G4CellScoreComposer::TrackEnters()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4error_propagation.so: undefined reference to `G4GeometryTolerance::GetInstance()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4run.so: undefined reference to `G4PrimaryParticle::G4PrimaryParticle(G4ParticleDefinition*, double, double, double)' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4intercoms.so: undefined reference to `G4UnitDefinition::PrintUnitsTable()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4readout.so: undefined reference to `G4SDManager::GetSDMpointer()' /usr/local/geant4.9.3.p02/lib/Linux-g++/libG4error_propagation.so: undefined reference to `G4ComptonScattering::G4ComptonScattering(G4String const&, G4ProcessType)'

echo $LD_LIBRARY_PATH /usr/local/geant4.9.3.p02/lib/Linux-g++:/usr/local/lib:/usr/local/xerces-c-src_2_7_0/lib:/usr/local/lib:/usr/lib:/usr/local/root/lib:/usr/local/geant4.9.3.p02/lib:/usr/local/geant_vmc/lib/tgt_linux:/usr/local/geant3/lib/tgt_linux:/usr/local/vgm/lib/:/home/whit/sane08/InSANE/lib:/usr/local/xerces-c-src_2_7_0/lib:/usr/local/Canalyzer-1.5.12:/usr/local/geant4.9.3.p02/lib/Linux-g++:/usr/local/lib:/lib:/usr/local/lib:/usr/lib:/usr/local/root/lib:/usr/local/geant4.9.3.p02/lib:/usr/local/geant_vmc/lib/tgt_linux:/usr/local/geant3/lib/tgt_linux:/usr/local/vgm/lib/Linux-g++:/home/whit/sane08/InSANE/lib:/usr/local/xerces-c-src_2_7_0/lib:/usr/local/Canalyzer-1.5.12:/usr/local/geant4.9.3.p02/lib/Linux-g++:/usr/local/lib:/lib:/usr/local/lib:/usr/lib:/usr/local/root/lib:/usr/local/geant4.9.3.p02/lib:/usr/local/geant_vmc/lib/tgt_linux:/usr/local/geant3/lib/tgt_linux:/usr/local/vgm/lib:/home/whit/sane08/InSANE/lib:/usr/local/xerces-c-src_2_7_0/libs

Thanks!

To build geant4_vmc without VGM, it should be sufficient just not to export the variable USE_VGM; have you tried to do this before commenting out the code, headers etc. ?
I am out of the office this week, so I would be able to investigate your problem only next week. In meantime, could you let me know which VGM building system did you use and if you tried to run the VGM test or examples to check its installation itself?

Thank you,

Thanks for your reply. But I figured out what I was doing wrong!!!

I learned a coding lesson the hard way. I had a bunch of includes in a header file, which I assume had all sorts of preprocessor commands that got mixed up with other ones… This is bad form, because includes should be placed into the cpp files, not headers, unless it is impossible otherwise.

While the errors have gone away in my code, I still cannot compile geant4_vmc.

I see this post,[url]Rootcint and ROOTSYS , but it is unclear what I should do.

Ok. So I found an environment variable that was being used, (OGLFLAGS) which had -I/usr/include.
Removing this from the flag fixed everything! Not sure why I had it set like that in the first place. 8)

Cheers,
Whit

Dear Whit,

Thanks for your investigations, I was glad to hear that the problem is solved.

Best regards,

1 Like