Compiling extanded/electromagnetic example Test Em5

Hello. hope you are doing well!
I want to compile and run the extended/electromagnetic example TestEm5 in Geant4.10.06.p01 on ubuntu 19.10.But i am getting error after the command ./example_TestEm5 just after the make command. I attached the full text here. Need your suggestions to solve this. Thanks.

afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build$ cmake …
– The C compiler identification is GNU 9.2.1
– The CXX compiler identification is GNU 9.2.1
– 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
CMake Error at CMakeLists.txt:13 (find_package):
By not providing “FindGeant4.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “Geant4”, but
CMake did not find one.

Could not find a package configuration file provided by “Geant4” with any
of the following names:

Geant4Config.cmake
geant4-config.cmake

Add the installation prefix of “Geant4” to CMAKE_PREFIX_PATH or set
“Geant4_DIR” to a directory containing one of the above files. If “Geant4”
provides a separate development package or SDK, be sure it has been
installed.

– Configuring incomplete, errors occurred!
See also “/home/afzaal/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build/CMakeFiles/CMakeOutput.log”.
afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build$ source /home/afzaal/PET/Geant4/geant4.10.06.p01-install/bin/geant4.sh
afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build$ cmake …
– Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found suitable version “2.2.7”, minimum required is “2.2.7”)
– Found XercesC: /usr/lib/x86_64-linux-gnu/libxerces-c.so (found suitable version “3.2.2”, minimum required is “3.2.2”)
– Found X11: /usr/include
– 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 OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
– Configuring done
– Generating done
– Build files have been written to: /home/afzaal/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build
afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build$ make
Scanning dependencies of target TestEm5
[ 4%] Building CXX object CMakeFiles/TestEm5.dir/TestEm5.cc.o
[ 9%] Building CXX object CMakeFiles/TestEm5.dir/src/ActionInitialization.cc.o
[ 13%] Building CXX object CMakeFiles/TestEm5.dir/src/DetectorConstruction.cc.o
[ 18%] Building CXX object CMakeFiles/TestEm5.dir/src/DetectorMessenger.cc.o
[ 22%] Building CXX object CMakeFiles/TestEm5.dir/src/EventAction.cc.o
[ 27%] Building CXX object CMakeFiles/TestEm5.dir/src/HistoManager.cc.o
[ 31%] Building CXX object CMakeFiles/TestEm5.dir/src/PhysListEm19DStandard.cc.o
[ 36%] Building CXX object CMakeFiles/TestEm5.dir/src/PhysListEm5DStandard.cc.o
[ 40%] Building CXX object CMakeFiles/TestEm5.dir/src/PhysListEmStandard.cc.o
[ 45%] Building CXX object CMakeFiles/TestEm5.dir/src/PhysicsList.cc.o
[ 50%] Building CXX object CMakeFiles/TestEm5.dir/src/PhysicsListMessenger.cc.o
[ 54%] Building CXX object CMakeFiles/TestEm5.dir/src/PrimaryGeneratorAction.cc.o
[ 59%] Building CXX object CMakeFiles/TestEm5.dir/src/PrimaryGeneratorMessenger.cc.o
[ 63%] Building CXX object CMakeFiles/TestEm5.dir/src/Run.cc.o
[ 68%] Building CXX object CMakeFiles/TestEm5.dir/src/RunAction.cc.o
[ 72%] Building CXX object CMakeFiles/TestEm5.dir/src/StackingAction.cc.o
[ 77%] Building CXX object CMakeFiles/TestEm5.dir/src/StackingMessenger.cc.o
[ 81%] Building CXX object CMakeFiles/TestEm5.dir/src/StepMax.cc.o
[ 86%] Building CXX object CMakeFiles/TestEm5.dir/src/SteppingAction.cc.o
[ 90%] Building CXX object CMakeFiles/TestEm5.dir/src/SteppingVerbose.cc.o
[ 95%] Building CXX object CMakeFiles/TestEm5.dir/src/TrackingAction.cc.o
[100%] Linking CXX executable TestEm5
[100%] Built target TestEm5
afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build$ ./example_TestEm5
afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/exafzaaafzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended
/electromagnetic/TestEm5/build$ ./example_TestEm5
afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build$ ./example_TestEm5
bash: ./example_TestEm5: No such file or directory
afzaal@afzaal-HP-Laptop-15-bw0xx:~/PET/Geant4/geant4.10.06.p01/examples/extended/electromagnetic/TestEm5/build$

It seems like an error not finding the source of Geant4 which is your cmake command before doing make? it should be something like:

cmake -DGeant4_DIR=[directory containing the Geant4 install] [source_directory]

Also did you configure the Geant4 bin files? i.e. running:
source [directory containing the Geant4 intall]/bin/geant4.sh

Cheers,
Juan

Thanks for your response.
When i entered command
cmake -DGeant4_DIR=[directory containing the Geant4 install] [source_directory]
error appeared(screenshot attached).

The source directory is where the code of your application is. In your case, because is an example, should be something like [Geant4 intall]/share/Geant4.10.6.0/examples/basic/B5

Thanks if i did’t correct type then please check it.

Probably I didn’t explain me well, but I was only correcting the last part of the command. In your case the command should be like
cmake -DGeant4_DIR=/home/afzaal/PET/Geant4/geant4.10.06.p01-install/ /home/afzaal/PET/Geant4/geant4.10.06.p01-install/share/examples/extended/electromagnetic/TestEm5/

and should be run from the build directory for your application. Also, check that the directory paths point to the right places 'cause I’m guessing some of them.