B1 not producing graphics! No current viewer, how to properly load graphics and other libraries?

This is very much related to this question, which is still open and no solution has been posted in a month or so, I commented my question there and have not received any response in 24 hours, therefore I am going to post it as a new topic. This comment also seems helpful but not sure what they meant by:

I configured to use Qt and see:

Available UI session types: [ Qt, GAG, tcsh, csh ]

where did they configure that?

Following this suggestion. I did geant4-config --help and got (part of) the output:

Known Features:
staticlibs[no]
multithreading[no]
smartstack[no]
clhep[yes]
expat[no]
zlib[yes]
gdml[no]
usolids[no]
freetype[no]
hdf5[no]
g3tog4[no]
qt[no]
motif[no]
raytracer-x11[no]
opengl-x11[no]
openinventor[no]

I did turn a lot of options ON including Qt, using:

cmake -DGEANT4_INSTALL_DATA=ON ../geant4.10.06.p01/ 
cmake -DGEANT4_USE_RAYTRACER_X11=ON ../geant4.10.06.p01/
cmake -DGEANT4_USE_OPENGL_X11=ON ../geant4.10.06.p01/
cmake -DGEANT4_USE_QT=ON ../geant4.10.06.p01/

Considering "${SOFTWARE}/academic" as my default path for all installations, here are the Geant4, CLHEP, ROOT etc, paths in my ~/.bashrc

# FOR CERN ROOT
export ROOTSYS="${SOFTWARE}/academic/ROOT_BUILD"
export PATH=$PATH:${ROOTSYS}/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${ROOTSYS}/lib

# FOR CLHEP
export CLHEP_DIR="${SOFTWARE}/academic/clhep/install"
export CLHEP_INCLUDE_DIR="${CLHEP_DIR}/include/"
export CLHEP_LIBRARY="${CLHEP_DIR}/lib/"
export LD_LIBRARY_PATH=${CLHEP_LIBRARY}:${LD_LIBRARY_PATH}
export PATH=${CLHEP_DIR}/bin:$PATH

# FOR GEANT4
GEANT4_WORK=${SOFTWARE}/academic/geant4/GEANT4_WORK 
source ${SOFTWARE}/academic/geant4/install/4.10.06.p01/bin/geant4.sh
source ${SOFTWARE}/academic/geant4/install/4.10.06.p01/share/Geant4-10.6.1/geant4make/geant4make.sh

During Geant4 installation, I created three directories: build, install/4.10.06.p01, GEANT4_WORK inside the parent ${SOFTWARE}/academic/geant4/ (contained the source). I have built everything from inside ${SOFTWARE}/academic/geant4/build.

To try the example B1, I did the following:

cp -r ${SOFTWARE}/academic/geant4//install/4.10.06.p01/share/Geant4-10.6.1/examples/basic/B1/ ${SOFTWARE}/academic/geant4/GEANT4_WORK/
cd ${SOFTWARE}/academic/geant4/GEANT4_WORK/B1/
export export G4WORKDIR=$SOFTWARE/academic/geant4/GEANT4_WORK/B1
make

and the output:

Making dependency for file exampleB1.cc ...
Making dependency for file src/B1SteppingAction.cc ...
Making dependency for file src/B1RunAction.cc ...
Making dependency for file src/B1EventAction.cc ...
Making dependency for file src/B1PrimaryGeneratorAction.cc ...
Making dependency for file src/B1ActionInitialization.cc ...
Making dependency for file src/B1DetectorConstruction.cc ...
Compiling B1DetectorConstruction.cc ...
Compiling B1ActionInitialization.cc ...
Compiling B1PrimaryGeneratorAction.cc ...
Compiling B1EventAction.cc ...
Compiling B1RunAction.cc ...
Compiling B1SteppingAction.cc ...
Creating shared library /mnt/bb47c2d1-aa7d-42ef-a4b2- 
33198d035691/atanu/Software/academic/geant4/GEANT4_WORK/B1/tmp/Linux- 
g++/exampleB1/libexampleB1.so ...
Compiling exampleB1.cc ...
Using global libraries ...
Linking exampleB1
... Done!

then (staying always inside B1)…

cp bin/Linux-g++/exampleB1 .
./exampleB1

And the output…

Available UI session types: [ GAG, tcsh, csh ]

**************************************************************
 Geant4 version Name: geant4-10-06-patch-01    (14-February-2020)
                       Copyright : Geant4 Collaboration
                      References : NIM A 506 (2003), 250-303
                                 : IEEE-TNS 53 (2006), 270-278
                                 : NIM A 835 (2016), 186-225
                             WWW : http://geant4.org/
**************************************************************

<<< Reference Physics List QBBC 
Visualization Manager instantiating with verbosity "warnings (3)"...
Visualization Manager initialising...
Registering graphics systems...

You have successfully registered the following graphics systems.
Current available graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRep (HepRepXML)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML1FILE (VRML1FILE)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)

Registering model factories...

You have successfully registered the following model factories.
Registered model factories:
  generic
  drawByAttribute
  drawByCharge
  drawByOriginVolume
  drawByParticleID
  drawByEncounteredVolume

Registered filter factories:
  attributeFilter
  chargeFilter
  originVolumeFilter
  particleFilter
  encounteredVolumeFilter

You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none

Some /vis commands (optionally) take a string to specify colour.
"/vis/list" to see available colours.
/control/saveHistory
/run/verbose 2
#
# Change the default number of threads (in multi-threaded mode)
#/run/numberOfThreads 4
#
# Initialize kernel
/run/initialize
userDetector->Construct() start.
Checking overlaps for volume Envelope (G4Box) ... OK! 
Checking overlaps for volume Shape1 (G4Cons) ... OK! 
Checking overlaps for volume Shape2 (G4Trd) ... OK! 
World is registered to the default region.
physicsList->Construct() start.
### Adding tracking cuts for neutron  TimeCut(ns)= 10000  KinEnergyCut(MeV)= 0
physicsList->CheckParticleList() start.
physicsList->setCut() start.
#
# Visualization setting
/control/execute vis.mac
# Macro file for the visualization setting in the initialization phase
# of the B1 example when running in interactive mode
#
# Use these open statements to open selected visualization
#
# Use this open statement to create an OpenGL view:
/vis/open OGL 600x600-0+0
/vis/sceneHandler/create OGL
parameter value (OGL) is not listed in the candidate List.
Candidates are: ATree DAWNFILE HepRepFile HepRepXML RayTracer VRML1FILE VRML2FILE gMocrenFile
#
# Use this open statement to create an OpenInventor view:
#/vis/open OI
#
# Use this open statement to create a .prim file suitable for
# viewing in DAWN:
#/vis/open DAWNFILE
#
# Use this open statement to create a .heprep file suitable for
# viewing in HepRApp:
#/vis/open HepRepFile
#
# Use this open statement to create a .wrl file suitable for
# viewing in a VRML viewer:
#/vis/open VRML2FILE
#
# Disable auto refresh and quieten vis messages whilst scene and
# trajectories are established:
/vis/viewer/set/autoRefresh false
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/verbose errors
Visualization verbosity changed to errors (2)
#
# Draw geometry:
/vis/drawVolume
/vis/scene/create
/vis/scene/add/volume world -1 -1 none m 0 0 0 0 0 0
/vis/sceneHandler/attach
ERROR: Current scene handler not defined.  Please select or create one.
#
# Specify view angle:
/vis/viewer/set/viewpointVector -1 0 0
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/viewer/set/lightsVector -1 0 0
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
#
# Specify style (surface, wireframe, auxiliary edges,...)
/vis/viewer/set/style wireframe
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/viewer/set/auxiliaryEdge true
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/viewer/set/lineSegmentsPerCircle 100
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
#
# Draw smooth trajectories at end of event, showing trajectory points
# as markers 2 pixels wide:
/vis/scene/add/trajectories smooth
/tracking/storeTrajectory 2
Attributes available for modeling and filtering with
  "/vis/modeling/trajectories/create/drawByAttribute" and
  "/vis/filtering/trajectories/create/attributeFilter" commands:
G4TrajectoriesModel:
  Event ID (EventID): G4int
  Run ID (RunID): G4int
G4SmoothTrajectory:
  Charge (Ch): unit: e+ (G4double)
  Track ID (ID): G4int
  Initial kinetic energy (IKE): G4BestUnit (G4double)
  Initial momentum magnitude (IMag): G4BestUnit (G4double)
  Initial momentum (IMom): G4BestUnit (G4ThreeVector)
  No. of points (NTP): G4int
  PDG Encoding (PDG): G4int
  Parent ID (PID): G4int
  Particle Name (PN): G4String
G4SmoothTrajectoryPoint:
  Auxiliary Point Position (Aux): G4BestUnit (G4ThreeVector)
  Step Position (Pos): G4BestUnit (G4ThreeVector)
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
/vis/scene/notifyHandlers scene-0
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2
/vis/scene/notifyHandlers scene-0
# (if too many tracks cause core dump => /tracking/storeTrajectory 0)
#
# Draw hits at end of event:
#/vis/scene/add/hits
#
# To draw only gammas:
#/vis/filtering/trajectories/create/particleFilter
#/vis/filtering/trajectories/particleFilter-0/add gamma
#
# To invert the above, drawing all particles except gammas,
# keep the above two lines but also add:
#/vis/filtering/trajectories/particleFilter-0/invert true
#
# Many other options are available with /vis/modeling and /vis/filtering.
# For example, to select colour by particle ID:
#/vis/modeling/trajectories/create/drawByParticleID
#/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true
# To select or override default colours (note: e+ is blue by default):
#/vis/modeling/trajectories/list
#/vis/modeling/trajectories/drawByParticleID-0/set e+ yellow
#
# To superimpose all of the events from a given run:
/vis/scene/endOfEventAction accumulate
ERROR: No current sceneHandler.  Please create one.
#
# Decorations
# Name
/vis/set/textColour green
/vis/set/textLayout right
/vis/scene/add/text2D 0.9 -.9 24 ! ! exampleB1
# or, if your system does not support right-adjustment
#/vis/scene/add/text2D 0 -.9 24 ! ! exampleB1
/vis/set/textLayout
/vis/set/textColour
#
# Axes, scale, etc.
/vis/scene/add/scale
ERROR: G4VisCommandSceneAddScale::SetNewValue: no viewer.
  Auto direction needs a viewer.
/vis/scene/add/axes
/vis/scene/add/eventID
/vis/scene/add/date
/vis/scene/add/logo2D
/vis/scene/add/logo
ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer.
  Auto direction needs a viewer.
#
# Frame
/vis/set/colour red
/vis/set/lineWidth 2
/vis/scene/add/frame
/vis/set/colour
/vis/set/lineWidth
#
# Attach text to one edge of Shape1, with a small, fixed offset
/vis/scene/add/text 0 6 -4 cm 18 4 4 Shape1
# Attach text to one corner of Shape2, with a small, fixed offset
/vis/scene/add/text 6 7 10 cm 18 4 4 Shape2
#
# To get nice view
# Make the "World" box invisible
/vis/geometry/set/visibility World 0 false
# "Envelope" is transparent blue to represent water
/vis/geometry/set/colour Envelope 0 0 0 1 .3
/vis/viewer/set/style surface
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/viewer/set/hiddenMarker true
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/viewer/set/viewpointThetaPhi 120 150
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
#
# Re-establish auto refreshing and verbosity:
/vis/viewer/set/autoRefresh true
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/verbose warnings
Visualization verbosity changed to warnings (3)
#
# For file-based drivers, use this to create an empty detector view:
#/vis/viewer/flush
Idle> 
Idle> 
Idle> 
Idle> 

I tried another building method, like creating a separate build directory and running cmake path_to_B1 and then make from within that build directory, and running the ./exampleB1 from the build, that too produced same output and failed.

Can anyone help me fix my Geant4, I will really appreciate any quick help.

Thanks

My system details:


OS: Ubuntu 18.04.4 LTS
cmake version 3.10.2
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
ROOT 6.10/04
CLHEP 2.4.1.3
____________________________________________________________
1 Like

That is my comment, I configured it in the same way you did, i.e. with the -DGEANT4_USE_QT=ON cmake option.

Looking at the exampleB1 output, Qt is not listed. Did you get any warnings/errors when running cmake with the Qt option? Also, did you run your build command after re-running cmake with the new options?

I did not build Geant4 with QT or other options ON, initially. Did it later… I just turned it OFF and ON again, here’s the output:

blahblah@...blahblah:/.../geant4/build/~$ cmake -DGEANT4_USE_QT=ON -DCMAKE_INSTALL_PREFIX=../install/4.10.06.p01/ ../geant4.10.06.p01/
-- Reusing dataset G4NDL (4.6)
-- Reusing dataset G4EMLOW (7.9.1)
-- Reusing dataset PhotonEvaporation (5.5)
-- Reusing dataset RadioactiveDecay (5.4)
-- Reusing dataset G4PARTICLEXS (2.1)
-- Reusing dataset G4PII (1.3)
-- Reusing dataset RealSurface (2.1.1)
-- Reusing dataset G4SAIDDATA (2.0)
-- Reusing dataset G4ABLA (3.1)
-- Reusing dataset G4INCL (1.0)
-- Reusing dataset G4ENSDFSTATE (2.2)
-- The following Geant4 features are enabled:
GEANT4_BUILD_CXXSTD: Compiling against C++ Standard '11'
GEANT4_USE_SYSTEM_EXPAT: Using system EXPAT library
GEANT4_USE_QT: Build Geant4 with Qt support

-- Configuring done
-- Generating done
-- Build files have been written to: ...blahblah:/.../geant4/build

I don’t see any warning.

Can you please run and post the output of the following command

$ ldd ./exampleB1 | grep -i qt
	libQt5OpenGL.so.5 => /usr/lib64/libQt5OpenGL.so.5 (0x00007f4a42110000)
	libQt5PrintSupport.so.5 => /usr/lib64/libQt5PrintSupport.so.5 (0x00007f4a42096000)
	libQt5Widgets.so.5 => /usr/lib64/libQt5Widgets.so.5 (0x00007f4a419ec000)
	libQt5Gui.so.5 => /usr/lib64/libQt5Gui.so.5 (0x00007f4a414ad000)
	libQt5Core.so.5 => /usr/lib64/libQt5Core.so.5 (0x00007f4a40f79000)

This is the output I get.

A friend suggested to do this:

/blah/blah/geant4/build~$ cmake -DGEANT4_INSTALL_DATA=ON - \
DGEANT4_INSTALL_DATADIR="../install/4.10.06.p01/share/Geant4-10.6.1/data/" \
-DCMAKE_INSTALL_PREFIX=../install/4.10.06.p01/ \
 -DCMAKE_PREFIX_PATH="/usr/lib/x86_64-linux-gnu/" \
-DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON \
 -DGEANT4_USE_GDML=ON -DGEANT4_BUILD_MULTITHREADED=ON ../geant4.10.06.p01/

This, actually did before too! But this time, I decided to make -j8 again and then make install again. After rebuilding it worked! Originally, I installed G4 without turning on those features, later I turned them on using:

cmake -DGEANT4_INSTALL_DATA=ON ../geant4.10.06.p01/

but didn’t make and make install again!

Now, B1 works fine. Although, this time I built B1 differently, created a build directory:

cmake -DCMAKE_INSTALL_PREFIX=../bin ../
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found suitable version "2.2.5", minimum required is "2.2.5") 
-- Found XercesC: /usr/lib/x86_64-linux-gnu/libxerces-c.so (found suitable version "3.2.0", minimum required is "3.2.0") 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Configuring done
-- Generating done
    -- Build files have been written to: /blah/blah/geant4/GEANT4_WORK/B1_Build

    /blah/blah/geant4/GEANT4_WORK/B1_Build~$
    /blah/blah/geant4/GEANT4_WORK/B1_Build~$ make -j8

Scanning dependencies of target exampleB1
[ 25%] Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o
[ 25%] Building CXX object CMakeFiles/exampleB1.dir/src/B1DetectorConstruction.cc.o
[ 37%] Building CXX object CMakeFiles/exampleB1.dir/src/B1ActionInitialization.cc.o
[ 50%] Building CXX object CMakeFiles/exampleB1.dir/src/B1RunAction.cc.o
[ 62%] Building CXX object CMakeFiles/exampleB1.dir/src/B1EventAction.cc.o
[ 75%] Building CXX object CMakeFiles/exampleB1.dir/src/B1PrimaryGeneratorAction.cc.o
[ 87%] Building CXX object CMakeFiles/exampleB1.dir/src/B1SteppingAction.cc.o
[100%] Linking CXX executable exampleB1
[100%] Built target exampleB1
Executables are rectory: /blah/blah/geant4/GEANT4_WORK/B1_Build
Done!

Then ./exampleB1 produced

:

I get the rest except this.

And now that returns:

 multithreading[yes]     # this was a 'no', I mean I originally didn't try to turn it on, turned on this time
 smartstack[no]
 clhep[yes]                  
 expat[no]
 zlib[yes]
 gdml[yes]                    # I did try to turn it on originally, had no effect, this time worked after re-building
 usolids[no]
 freetype[no]
 hdf5[no]
 g3tog4[no]
 qt[yes]                        # Qt was always 'NO' no matter how many times I switched it 'ON', this time worked
 motif[no]
 raytracer-x11[no]       # I didn't choose this one this time so I understand this being 'OFF', I have to rebuild
 opengl-x11[yes]         # was off originally         
 openinventor[no]