exampleB1.exe cannot find files that exist when executed

Geant4 version: 10.6

operating system and version: windows 10

compiler vendor and version: windows visual studio 2019

I am trying to build and run example B1 by following the installation guide instructions. In windows visual studio there are two ways of getting to the command prompt which produce different results. If I go to tools>>command line>>developer command prompt then apply the two commands: > cd % HOMEPATH% \Geant4\geant4_10_06_p02\B1-build\Release | and > exampleB1.exe | nothing happens. The command line returns this:

%HOMEPATH%\Geant4\geant4_10_06_p02\B1-build\Release>exampleB1.exe

%HOMEPATH%\Geant4\geant4_10_06_p02\B1-build\Release>

If instead I go to tools>>visual studio command prompt then apply the same two commands, the command line returns four error messages on separate windows (not on the command line window) that are almost identical. The errors windows displays this:

The code execution cannot proceed because ________ was not found. Reinstalling the program may help with this problem.

The blank contains a file name. Each of the four error messages contain a different filename. The four file names are G4GMocren.dll , G4visHepRep.dll , G4Tree.dll , and G4RayTracer.dll . These files are contained in the directory %HOMEPATH%\Geant4\geant4_10_06_p02\geant4_10_06-build\BuildProducts\Release\bin . Normally I would try to reinstall the program however I already did this. After I posted my previous question here I decided to delete all of the Geant4 files, reinstall the program, and start over. So it is very frustrating that the suggested course of action to solve my current problem is what I just did to solve my previous problem. Especially when (for me) this takes several hours of time.

In my previous post I had trouble creating an executable file for example B1 because windows visual studio couldn’t find a few files it needed to create it. Some of these files were similar to the ones that windows visual studio can’t find now. G4Tree.lib, G4GMocren.lib, G4visHepRep.lib, and G4RayTracer.lib were among these.

Below are the commands I used to get to this point.after, I downloaded the geant4 files.

cd %HOMEPATH%\Geant4\geant4_10_06_p02

mkdir geant4_10_06-build

cd %HOMEPATH%\Geant4\geant4_10_06_p02\geant4_10_06-build

cmake -DCMAKE_INSTALL_PREFIX="%HOMEPATH%\Geant4\geant4_10_06_p02\geant4_10_06-install" “%HOMEPATH%\Geant4\geant4_10_06_p02\geant4_10_06”

cmake build . config Release

cmake build . config Release target install

mkdir %HOMEPATH%\B1

Xcopy %HOMEPATH%\Geant4\geant4_10_06_p02\geant4_10_06\examples\basic\B1 %HOMEPATH%\B1 /E/H

cd %HOMEPATH%\Geant4\geant4_10_06_p02

mkdir B1-build

cd %HOMEPATH%\Geant4\geant4_10_06_p02\B1-build

cmake -DGeant4_DIR="%HOMEPATH%\Geant4\geant4_10_06_p02\geant4_10_06-build" “%HOMEPATH%\B1” > cmake build . config Release

cd %HOMEPATH%\Geant4\geant4_10_06_p02\B1-build\Release

exampleB1.exe

what do I do to execute example B1?
Any help would be greatly appreciated!

I have looked at other posts on this forum to try and get clues for what might be the problem and how to fix it. In this linux post it is mentioned in one of the command line outputs that some the graphic systems available are:

ASCIITree (ATree) DAWNFILE (DAWNFILE) G4HepRep (HepRepXML)

G4HepRepFile (HepRepFile) RayTracer (RayTracer) VRML1FILE (VRML1FILE)

VRML2FILE (VRML2FILE) gMocrenFile (gMocrenFile)

ASCIITree, G4HepRep, RayTracer, and gMocrenFile are important because the file names are similar to the files that were mentioned in the error messages. This means that the problem might have something to do with the graphic systems. I know this probably doesn’t help much but at least it is a step forward in isolating the problem. I’m not entirely sure if there is a set of commands in the installation guide that I need to use from the Building and Installing (Geant4 Build options) section and /or the Post Install section and /or How To Use The Geant4 Toolkit Libraries section. I didn’t use any commands from those sections to get to where I am now.

Any help or suggestions on how to proceed would be greatly appreciated!

I’d suspect that the PATH environment variable is not set to point the directory holding the Geant4 DLLs. Instructions on how to set that are in the PostInstall Setup instructions here:

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/InstallationGuide/html/postinstall.html#required-environment-settings-on-windows

Try following that for both PATH and the dataset environment variables, then run exampleB1.exe again. No need to rebuild it or Geant4 yet, just update the environment.

@bmorgan I went through the steps mentioned in the Installation guide/ post install setup /Required Environment Settings on Windows section. I navigated through the system/control panel options and windows to get to the environment variables. Under the user variables section was a variable named path . I added a value to that variable which was the directory that contains the dll files. I then manually managed the environment variables. I had to do this since I didn’t use the command cmake -DGEANT4_INSTALL_DATA=ON directly after configuring the build. (This is mentioned in the installation guide/ building and installing/ windows platforms and in the post install setup /Required Environment Settings on Windows sections). I downloaded all of the data files that were mentioned in post install setup/Environment Variables for datasets from the geant4 download page. (There are 12 files from the download page but only11 were mentioned in the Environment Variables for datasets section.) For each data file I unpacked it into it’s own directory. For each data set I added an environment variable (user variable). It’s variable name was the name listed environment variable/ value chart in the post install setup . It’s value is the directory where that the data file was unpacked. I then attempted again to run exampleB1.exe , and this happened:

%HOMEPATH%\Geant4\geant4_10_06_p02\B1-build\Release>exampleB1.exe

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

-------- WWWW ------- G4Exception-START -------- WWWW -------

*** ExceptionHandler is not defined ***

*** G4Exception : UI0002

issued by : G4UIExecutive::G4UIExecutive()

Specified session type is not build in your system,

or no session type is specified.

A fallback session type is used.

*** This is just a warning message. ***

-------- WWWW ------- G4Exception-END -------- WWWW -------

-------- EEEE ------- G4Exception-START -------- EEEE -------

*** G4Exception : PART70001

issued by : G4NuclideTable

ENSDFSTATE.dat is not found.

*** Fatal Exception *** core dump ***

Even though I find it frustrating to uninstall and reinstall again, I didn’t know how to make any progress otherwise (and as I have mentioned before reinstalling has fixed previous problems) so I deleted the Geant4 files and started using the commands I have mentioned in the original post above. First unpacked the source file to %HOMEPATH% \Geant4\Geant4.10.06 . Doing so created the directory %HOMEPATH% \Geant4\Geant4.10.06\geant4_10_06_p02.

I then used the commands:
cd %HOMEPATH% \Geant4\Geant4.10.06

mkdir %HOMEPATH% \Geant4\Geant4.10.06\geant4_10_06-build

cd %HOMEPATH%\Geant4\Geant4.10.06\geant4_10_06-build

cmake -DCMAKE_INSTALL_PREFIX="%HOMEPATH%\Geant4 ** Geant4.10.06 \geant4_10_06-install" "%HOMEPATH%\Geant4 ** Geant4.10.06\geant4_10_06"

The output of the last command came out as expected. I then tried a command I haven’t used yet cmake -DGEANT4_INSTALL_DATA=ON . From what I have read It appears that using this command will make things easier in the long run when trying to run exampleB1 (though I might be wrong about this).

When I used the command I got this as an output:

CMake Warning: No source or binary directory provided. Both will be assumed to be the same as the current working directory, but note that this warning will become a fatal error in future CMake releases. CMake Error: The source directory “%HOMEPATH%/Geant4/Geant4.10.06/geant4_10_06-build” does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.

So I changed directories from the build directory to the source directory. (Which contained the CmakeLists.txt and ran the command again.
%HOMEPATH%\Geant4\Geant4.10.06\geant4_10_06-build>cd %HOMEPATH%\Geant4\Geant4.10.06\geant4_10_06_p02

%HOMEPATH%\Geant4\Geant4.10.06\geant4_10_06_p02>cmake -DGEANT4_INSTALL_DATA=ON cmake -DGEANT4_INSTALL_DATA=ON

CMake Warning: No source or binary directory provided. Both will be assumed to be the same as the current working directory, but note that this warning will become a fatal error in future CMake releases. – Building for: Visual Studio 16 2019 – Geant4 requires an out-of-source build. – Please remove these files from %HOMEPATH%/Geant4/Geant4.10.06/geant4_10_06_p02 first: – CMakeCache.txt – CMakeFiles – Once these files are removed, create a separate directory – and run CMake from there CMake Error at CMakeLists.txt:13 (message): in-source build detected – Configuring incomplete, errors occurred!

My questions are below.

My goal is to run exampleB1. Those that are reading this can answer the questions at their discretion to help me achieve that goal. If you see a clear path way that allows me to execute exampleB1 without answering some or any of the questions below I would be happy to see that. These questions are just areas where I think the problems or potential problems might be along the way. They do not all have to be answered.

  1. Before uninstalling and reinstalling was there a simple fix that I could have performed that would have potentially allowed me to run exampleB1?

  2. Did follow the post install instructions correctly?

  3. Is helpful for me to use cmake -DGEANT4_INSTALL_DATA=ON ? (In other words, is faster, more simple, easier to use this command then not use this command?)

  4. [If yes to 3)] should I remove CmakeCache.txt and CmakeFiles as instructed or move them somewhere else that they can be found later? In the output of the last command above When it says “create a separate directory and run cmake from there”. Where should this directory be? Does it have any restrictions on what it can be named?

  5. [if yes to 3)] If I Remove or move the CmakeCache.txt and CmakeFiles do I have to change or add any commands that are given in the installation guide when configuring Geant4 and running exampleB1?

  6. Do I have to install the 11 data files again?

  7. What do I do next in order to run exampleB1?

Any help would be appreciated!!!

The error in running exampleB1 is due to the environment variables for the data not being set in the session it is run in. You can see what variables are set from the command prompt by running the set command. That should print all the variables and you can check the ones for the data libraries are set and point in the right places.

Yes, this will download and install the data for you, but it will not set the environment variables for you. Those steps still need to be done manually.

I don’t know what happened here. Assuming that you ran cmake -DGEANT4_INSTALL_DATA=ON . in %HOMEPATH%\Geant4\Geant4.10.06\geant4_10_06-build then it should not have complained.

Geant4’s CMake build enforces a strict separation between source and build to avoid mixing generated and actual source. If you have CMakeCache.txt and CMakeFiles/ in %HOMEPATH%\Geant4\Geant4.10.06\geant4_10_06_p02 then you should remove them.

You don’t need to change/add any commands, just cd back into %HOMEPATH% \Geant4\Geant4.10.06\geant4_10_06-build. That’s the build directory and where you can run cmake commands in.
[/quote]

No, if they are already present on your system, that’s all that’s needed apart from setting the environment variables to point to them.

First, check that the session you are running in has the data environment variables set, using the command outlined earlier. Second, if you’re rebuilding/installing Geant4 again, you may want to add -DGEANT4_USE_OPENGL_WIN32=ON to the cmake options. That will enable a better visualisation system that will be helpful later.

from the B1-build file enter

.\Release\exampleB1.exe