This text concerns mainly Linux-g++ and Darwin-g++ (MacOS) users.
For the time being, these are the only systems on which ROOT is configured and built
with the "--enable-thread" option by default.
This text, however, may also be helpful for people working on other
systems, if they configure and build ROOT with
"--enable-thread".
The problem is that, for the time being, Geant4 is not "thread
aware" at all, and mixing ROOT and Geant4 (both use
X11/Xt/Motif/GL) leads to serious problems. For details (sorted by
date), see:
In order to "fight" these problems, you may try the following:
- The minimal solution, recommended
above by a Geant4 team member, would be to put a call to
XInitThreads() in
the beginning of the main() routine of your Geant4 application. If this
solution works for you, you are done.
Note, however, that, when linking your application program with both
ROOT and Geant4 libraries, you should probably exclude ROOT Thread and
system thread libraries and all other related compiler flags (you also
need to remember to set the
"Unix.*.Root.UseThreads" to "false" in the system default
${ROOTSYS}/etc/system.rootrc and in your ${HOME}/.rootrc, if it exists).
- The general disadvantage of the above solution is that you will
be using a "mixed" code, part of which is compiled with the "thread"
option enabled and another part with the same option disabled.
Many people encountered problems in similar situations.
It is clear that, in "long term", the Geant4 will also become a
"thread aware" toolkit ...
You can try it now ... the geant4.thread.patches.tar.gz
archive contains three tar.gz files:
- geant4.7.1.patches.tar.gz
- geant4.7.0.p01.patches.tar.gz
- geant4.6.2.p02.patches.tar.gz
These files contain patches to appropriate Geant4 sources and to
both, the "Linux-g++.gmk" and the "Darwin-g++.gmk" (MacOS) files
(people working on other systems can also use these patches, but
they, IN ADDITION, need to modify the appropriate system specific
"gmk" file - see "Linux-g++.gmk" and "Darwin-g++.gmk" for hints).
They are prepared for, respectively, geant4.7.1,
geant4.7.0.p01 (this file works for geant4.7.0, too) and
geant4.6.2.p02 (note also that all these tar.gz files may
contain some additional Geant4 fixes, not related to ROOT and or
threads). It should be easy to "port" them to any Geant4 release
one uses, no ROOT-version specific modifications at all.
If you plan to use the G4UIRoot,
you should apply the above patches AFTER applying G4UIRoot
patches (the G4UIRoot
"interactivity.gmk" needs to be overwritten).
The best would be to make a "fresh" Geant4
installation, copy the
changed files from (the G4UIRoot first and later from) the above
archives and make a new "./Configure
-build" in Geant4.
Note, however, that these patches do not make the Geant4 a
"multithreaded" toolkit. They make it only "thread aware". In
particular a call to XInitThreads is added in places where Geant4
possibly "opens" the X11 display, and sources are compiled with the
"thread" option (if you are using "external" libraries like, for
example, the OpenInventor,
you should make sure that they are "thread
aware", too).
When using these patches, you should also carefully inspect your
makefiles and/or scripts that make/create your Geant4
libraries/applications. Possibly existing lines in form, e.g.:
- ROOTCFLAGS := $(filter-out -D_REENTRANT,$(ROOTCFLAGS))
- ROOTCFLAGS := $(filter-out -pthread,$(ROOTCFLAGS))
- ROOTLIBS := $(filter-out -lThread,$(ROOTLIBS))
- ROOTLIBS := $(filter-out -lpthread,$(ROOTLIBS))
- ROOTLIBS := $(filter-out -pthread,$(ROOTLIBS))
should be removed (or commented out).
- Finally, one could also try to configure and build ROOT setting
"--disable-thread". This is not really recommended as nowadays the
"thread" option is considered "mandatory" for all LHC applications.
Last but not least, note that you may also face an OpenGL bug mentioned in one of the above
"references", which is not Geant4 nor ROOT specific. For details, see
once again:
- http://root.cern.ch/root/roottalk/roottalk04/3177.html
Hope it helps,
Best regards,
Jacek M. Holeczek. (last change: Fri Oct 7 13:31:48 CEST 2005)