Running Basic example B1

Hello, i have used this link to install Geant4.10.06.p01 on ubuntu 19.10
https://indico.tifr.res.in/indico/getFile.py/access?contribId=29&resId=0&materialId=slides&confId=5309
I am using the same link to run basic example B1
but i can’t figure out it and the error is in the screenshot attached.


Any help would be really appreciable.
Thanks for your time and consideration

Copy your exampleB1 from geant4/examples to another directory.
And create a new directory named build iside B1 and with your terminal place on exampleB1/build and use this commands:
1- cmake …
2- make
3- ./exampleB1
I hope this can be helpful

Thanks for you response.
I copy example B1 to home directory and created another directory build inside it. But, when i run cmake command with terminal place on B1/build and as well on B1-build in the examples directory then this same error appeared.(screenshot attached)
Screenshot from 2020-04-21 15-22-43|690x387 .
Again taking your time for consideration.
Thanks.

Please see the How to build an application guide.

cmake. . not cmake …

That’s not correct either! It’s “cmake ..” i.e. using “dotdot” (no space) to refer to the directory above the current working one.

With terminal place is at B1-build and with command
cmake -DGeant4_DIR=/home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/Geant4-10.6.1 /home/afzaal/B1
build file has been written to /home/afzaal/B1 instead of /home/afzaal/B1-build
and the error is

I think what’s happened is that cmake was previously run in /home/afzaal/B1 and that has created the CMakeCache.txt, cmake_install.cmake and Makefile files, and the CMakeFiles/ directory.

When cmake is run again in B1-build, pointing it to the source directory at /home/afzaal/B1, CMake thinks this is the build directory (because of the presence of the files above).

To fix this, go into /home/afzaal/B1 and remove:

  • CMakeCache.txt
  • cmake_install.cmake
  • Makefile
  • CMakeFiles/

Then go back to ~/B1-build and remove any files that are in it. Running

cmake -DGeant4_DIR=/home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/Geant4-10.6.1 /home/afzaal/B1

in ~/B1-build should then work.

Thanks your response really helped me a lot. I have successfully built file in B1-build but still getting error at the end.(Screenshot attached)

This might be due to Ubuntu’s linker behaviour. Could you run:

$ ldd ./exampleB1

and

$ readelf -d ./exampleB1

and post the output here please?

here is the output when i entered commands
ldd ./exampleB1 and readelf -d ./exampleB1

We can’t scroll the terminal output in the screenshot you posted. Can you please copy and paste it so we can see it all.

afzaal@afzaal-HP-Laptop-15-bw0xx:~ cd B1-build afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build cmake -DGeant4_DIR=/home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/Geant4-10.6.1 /home/afzaal/B1
– Configuring done
– Generating done
– Build files have been written to: /home/afzaal/B1-build
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ make -j4
[100%] Built target exampleB1
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ ./exampleB1
./exampleB1: error while loading shared libraries: libG4graphics_reps.so: cannot open shared object file: No such file or directory
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ ldd ./exampleB1
linux-vdso.so.1 (0x00007ffeb11b1000)
libG4Tree.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4Tree.so (0x00007f2ee4686000)
libG4GMocren.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4GMocren.so (0x00007f2ee4636000)
libG4visHepRep.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4visHepRep.so (0x00007f2ee4596000)
libG4RayTracer.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4RayTracer.so (0x00007f2ee4566000)
libG4VRML.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4VRML.so (0x00007f2ee4546000)
libG4OpenGL.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4OpenGL.so (0x00007f2ee44a6000)
libG4interfaces.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4interfaces.so (0x00007f2ee440e000)
libG4physicslists.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4physicslists.so (0x00007f2ee424e000)
libG4FR.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4FR.so (0x00007f2ee4236000)
libG4vis_management.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4vis_management.so (0x00007f2ee411e000)
libG4modeling.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4modeling.so (0x00007f2ee4016000)
libG4run.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4run.so (0x00007f2ee3f86000)
libG4event.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4event.so (0x00007f2ee3f06000)
libG4tracking.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4tracking.so (0x00007f2ee3eb6000)
libG4analysis.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4analysis.so (0x00007f2ee399e000)
libG4particles.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4particles.so (0x00007f2ee3876000)
libG4geometry.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4geometry.so (0x00007f2ee358e000)
libG4materials.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4materials.so (0x00007f2ee34ae000)
libG4intercoms.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4intercoms.so (0x00007f2ee343e000)
libG4global.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4global.so (0x00007f2ee33de000)
libG4clhep.so => /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4clhep.so (0x00007f2ee3336000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2ee3126000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2ee3106000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2ee2f0e000)
libG4graphics_reps.so => not found
libG4digits_hits.so => not found
libG4graphics_reps.so => not found
libG4graphics_reps.so => not found
libG4zlib.so => not found
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2ee2dbe000)
libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f2ee2c7e000)
libG4processes.so => not found
libG4digits_hits.so => not found
libG4graphics_reps.so => not found
libG4graphics_reps.so => not found
libG4gl2ps.so => not found
libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f2ee2be6000)
libXmu.so.6 => /lib/x86_64-linux-gnu/libXmu.so.6 (0x00007f2ee2bc6000)
libQt5OpenGL.so.5 => /lib/x86_64-linux-gnu/libQt5OpenGL.so.5 (0x00007f2ee2b66000)
libQt5Widgets.so.5 => /lib/x86_64-linux-gnu/libQt5Widgets.so.5 (0x00007f2ee24c6000)
libG4graphics_reps.so => not found
libQt5Gui.so.5 => /lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f2ee1ede000)
libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f2ee1996000)
libG4processes.so => not found
libG4track.so => not found
libG4graphics_reps.so => not found
libG4digits_hits.so => not found
libG4graphics_reps.so => not found
libG4digits_hits.so => not found
libG4graphics_reps.so => not found
libG4processes.so => not found
libG4digits_hits.so => not found
libG4graphics_reps.so => not found
libG4digits_hits.so => not found
libG4track.so => not found
libG4graphics_reps.so => not found
libG4processes.so => not found
libG4track.so => not found
libG4graphics_reps.so => not found
libG4zlib.so => not found
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f2ee1966000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2ee46b6000)
libG4graphics_reps.so => not found
libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f2ee1936000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2ee192e000)
libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f2ee18f6000)
libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f2ee1836000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2ee180e000)
libXt.so.6 => /lib/x86_64-linux-gnu/libXt.so.6 (0x00007f2ee159e000)
libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f2ee1586000)
libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f2ee154e000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2ee152e000)
libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f2ee1436000)
libicui18n.so.63 => /lib/x86_64-linux-gnu/libicui18n.so.63 (0x00007f2ee114e000)
libicuuc.so.63 => /lib/x86_64-linux-gnu/libicuuc.so.63 (0x00007f2ee0f76000)
libpcre2-16.so.0 => /lib/x86_64-linux-gnu/libpcre2-16.so.0 (0x00007f2ee0ef6000)
libdouble-conversion.so.3 => /lib/x86_64-linux-gnu/libdouble-conversion.so.3 (0x00007f2ee0ede000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f2ee0db6000)
libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f2ee0dae000)
libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f2ee0da6000)
libSM.so.6 => /lib/x86_64-linux-gnu/libSM.so.6 (0x00007f2ee0d96000)
libICE.so.6 => /lib/x86_64-linux-gnu/libICE.so.6 (0x00007f2ee0d76000)
libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f2ee0cb6000)
libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f2ee0c86000)
libicudata.so.63 => /lib/x86_64-linux-gnu/libicudata.so.63 (0x00007f2edf28e000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f2edf216000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f2edf1f6000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f2edf1e6000)
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ readelf -d ./exampleB1

Dynamic section at offset 0xe7e8 contains 51 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libG4Tree.so]
0x0000000000000001 (NEEDED) Shared library: [libG4GMocren.so]
0x0000000000000001 (NEEDED) Shared library: [libG4visHepRep.so]
0x0000000000000001 (NEEDED) Shared library: [libG4RayTracer.so]
0x0000000000000001 (NEEDED) Shared library: [libG4VRML.so]
0x0000000000000001 (NEEDED) Shared library: [libG4OpenGL.so]
0x0000000000000001 (NEEDED) Shared library: [libG4interfaces.so]
0x0000000000000001 (NEEDED) Shared library: [libG4physicslists.so]
0x0000000000000001 (NEEDED) Shared library: [libG4FR.so]
0x0000000000000001 (NEEDED) Shared library: [libG4vis_management.so]
0x0000000000000001 (NEEDED) Shared library: [libG4modeling.so]
0x0000000000000001 (NEEDED) Shared library: [libG4run.so]
0x0000000000000001 (NEEDED) Shared library: [libG4event.so]
0x0000000000000001 (NEEDED) Shared library: [libG4tracking.so]
0x0000000000000001 (NEEDED) Shared library: [libG4analysis.so]
0x0000000000000001 (NEEDED) Shared library: [libG4particles.so]
0x0000000000000001 (NEEDED) Shared library: [libG4geometry.so]
0x0000000000000001 (NEEDED) Shared library: [libG4materials.so]
0x0000000000000001 (NEEDED) Shared library: [libG4intercoms.so]
0x0000000000000001 (NEEDED) Shared library: [libG4global.so]
0x0000000000000001 (NEEDED) Shared library: [libG4clhep.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000001d (RUNPATH) Library runpath: [/home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib:]
0x000000000000000c (INIT) 0x6000
0x000000000000000d (FINI) 0xb198
0x0000000000000019 (INIT_ARRAY) 0xf3b8
0x000000000000001b (INIT_ARRAYSZ) 64 (bytes)
0x000000000000001a (FINI_ARRAY) 0xf3f8
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x3a0
0x0000000000000005 (STRTAB) 0x1608
0x0000000000000006 (SYMTAB) 0x3f0
0x000000000000000a (STRSZ) 8209 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000015 (DEBUG) 0x0
0x0000000000000003 (PLTGOT) 0xfb58
0x0000000000000002 (PLTRELSZ) 2904 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x4680
0x0000000000000007 (RELA) 0x3870
0x0000000000000008 (RELASZ) 3600 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000006ffffffe (VERNEED) 0x37a0
0x000000006fffffff (VERNEEDNUM) 3
0x000000006ffffff0 (VERSYM) 0x361a
0x000000006ffffff9 (RELACOUNT) 76
0x0000000000000000 (NULL) 0x0
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$

do you have geant4 libraries in geant4 source directory? and check the address of geant4 libraries in geant4installdata.cmake file.

also you can install synaptic package manager in your linux system then install the libraries like libg4gemetry.so and all libraries that you did not install.

Thanks for the full output! I’m almost sure this is due to a linking issue related to Ubuntu/ld/etc, but I’m going to have to dig into exactly what’s changed.

Could you run:

$ readelf -d /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4OpenGL.so 

and as above post the output text here please?

Then could you try running

$ source /home/afzaal/PET/Geant4/geant4.10.06.p01-install/bin/geant4.sh
$ ./exampleB1

I suspect that this will run, or at least get to the point about missing data. Let’s see what happens with these, then can look at a recommended solution.

Thanks a lot. It really helped me to complete exampleB1.
afzaal@afzaal-HP-Laptop-15-bw0xx:~ cd B1-build afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build make -j4
[100%] Built target exampleB1
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ readelf -d /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4OpenGl.so
readelf: Error: ‘/home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4OpenGl.so’: No such file
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ readelf -d /home/afzaal/PET/Geant4/geant4.10.06.p01-install/lib/libG4OpenGL.so

Dynamic section at offset 0x94990 contains 45 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libG4gl2ps.so]
0x0000000000000001 (NEEDED) Shared library: [libG4interfaces.so]
0x0000000000000001 (NEEDED) Shared library: [libG4vis_management.so]
0x0000000000000001 (NEEDED) Shared library: [libGL.so.1]
0x0000000000000001 (NEEDED) Shared library: [libX11.so.6]
0x0000000000000001 (NEEDED) Shared library: [libXmu.so.6]
0x0000000000000001 (NEEDED) Shared library: [libQt5OpenGL.so.5]
0x0000000000000001 (NEEDED) Shared library: [libQt5Widgets.so.5]
0x0000000000000001 (NEEDED) Shared library: [libG4modeling.so]
0x0000000000000001 (NEEDED) Shared library: [libG4run.so]
0x0000000000000001 (NEEDED) Shared library: [libG4geometry.so]
0x0000000000000001 (NEEDED) Shared library: [libG4graphics_reps.so]
0x0000000000000001 (NEEDED) Shared library: [libG4intercoms.so]
0x0000000000000001 (NEEDED) Shared library: [libG4global.so]
0x0000000000000001 (NEEDED) Shared library: [libG4clhep.so]
0x0000000000000001 (NEEDED) Shared library: [libQt5Gui.so.5]
0x0000000000000001 (NEEDED) Shared library: [libQt5Core.so.5]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000e (SONAME) Library soname: [libG4OpenGL.so]
0x000000000000000c (INIT) 0x2a000
0x000000000000000d (FINI) 0x7a560
0x0000000000000019 (INIT_ARRAY) 0x91b28
0x000000000000001b (INIT_ARRAYSZ) 208 (bytes)
0x000000000000001a (FINI_ARRAY) 0x91bf8
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x2f0
0x0000000000000005 (STRTAB) 0xa9a0
0x0000000000000006 (SYMTAB) 0x1b50
0x000000000000000a (STRSZ) 63350 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x96000
0x0000000000000002 (PLTRELSZ) 21936 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x24430
0x0000000000000007 (RELA) 0x1aea8
0x0000000000000008 (RELASZ) 38280 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffffe (VERNEED) 0x1acf8
0x000000006fffffff (VERNEEDNUM) 8
0x000000006ffffff0 (VERSYM) 0x1a116
0x000000006ffffff9 (RELACOUNT) 221
0x0000000000000000 (NULL) 0x0
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ source /home/afzaal/PET/Geant4/geant4.10.06.p01-install/bin/geant4.sh
afzaal@afzaal-HP-Laptop-15-bw0xx:~/B1-build$ ./exampleB1
Available UI session types: [ Qt, GAG, tcsh, csh ]

Great! I think for your case, sourcing the geant4.sh script is the best solution for now, and will work reliably.

The underlying issue is down to how libraries are getting linked and their R/RUNPATHS being set and used on Ubuntu. We’ll need to investigate further to determine if there are any issue with the Geant4 CMake scripts here, but sourcing that script will do the job in the meantime.

1 Like

Is sourcing the geant4.sh file still the best way to solve this issue (I am having same issue after new installation on Ubuntu 20.04.1)? Can I just put the source command in .bashrc file to avoid having to run it in the terminal?

Don’t put it into your .bashrc. It sets environment variables (like PATH), and you don’t want it to be run every time you fork a child shell (e.g., when running a script). If you don’t want to do it by hand, put it into your .profile/.bash_profile.