Problem Running Example B1

Hello!
I just set up Geant4 10.5 with Windows 10, Visual Studio 2019, and CMake 3.14.3.
I’m trying to run example B1. I’ve followed the directions in http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/InstallationGuide/html/quickstart.html until I got an error message after running “cmake --build . --config Release”. The error message is copied below.
C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-build> cmake --build . --config Release
Microsoft ® Build Engine version 16.0.461+g6ff56ef63c for .NET Framework
Copyright © Microsoft Corporation. All rights reserved.
exampleB1.cc
C:\Users\Ellie\Desktop\B1\include\B1DetectorConstruction.hh(33): fatal error C1083
: Cannot open include file: ‘G4VUserDetectorConstruction.hh’: No such file or dire
ctory [C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-b
uild\exampleB1.vcxproj]
B1ActionInitialization.cc
C:\Users\Ellie\Desktop\B1\include\B1ActionInitialization.hh(33): fatal error C1083
: Cannot open include file: ‘G4VUserActionInitialization.hh’: No such file or dire
ctory [C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-b
uild\exampleB1.vcxproj]
B1DetectorConstruction.cc
C:\Users\Ellie\Desktop\B1\include\B1DetectorConstruction.hh(33): fatal error C1083
: Cannot open include file: ‘G4VUserDetectorConstruction.hh’: No such file or dire
ctory [C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-b
uild\exampleB1.vcxproj]
B1EventAction.cc
C:\Users\Ellie\Desktop\B1\include\B1EventAction.hh(33): fatal error C1083: Cannot
open include file: ‘G4UserEventAction.hh’: No such file or directory [C:\Users\Ell
ie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-build\exampleB1.vcxp
roj]
B1PrimaryGeneratorAction.cc
C:\Users\Ellie\Desktop\B1\include\B1PrimaryGeneratorAction.hh(33): fatal error C10
83: Cannot open include file: ‘G4VUserPrimaryGeneratorAction.hh’: No such file or
directory [C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build
B1-build\exampleB1.vcxproj]
B1RunAction.cc
C:\Users\Ellie\Desktop\B1\include\B1RunAction.hh(33): fatal error C1083: Cannot op
en include file: ‘G4UserRunAction.hh’: No such file or directory [C:\Users\Ellie\D
esktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-build\exampleB1.vcxproj]
B1SteppingAction.cc
C:\Users\Ellie\Desktop\B1\include\B1SteppingAction.hh(33): fatal error C1083: Cann
ot open include file: ‘G4UserSteppingAction.hh’: No such file or directory [C:\Use
rs\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-build\exampleB
1.vcxproj]
Generating Code…
I’ve verified that all of the .hh files that are mentioned are present in the B1 directory under include.
What should I try next? Thanks.

1 Like

Where is your install of Geant4 located, and what did you set Geant4_DIR to when you configured the example? The headers it can’t find are from the core Geant4 interface, so it feels like CMake has found this correctly, but something is otherwise wrong with the install, permissions, or possible bugs with path setup.

My install of Geant4 is located at C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01. I set Geant4_DIR to C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build. Thanks!

Thanks! Just to confirm, is there a file named Geant4Config.cmake in C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build ?

Could you also try running the build of the example as:

>  cmake --build .  --verbose --config Release

This won’t solve things, but should show the full compiler command(s) used and what paths headers were searched for under. That output might get long so attach it to this thread in a text file if needed.

Ok, thanks! There is a Geant4Config.cmake file in C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build.
Here’s what I got after running cmake --build . --verbose --config Release.
Geant4 error.txt (23.3 KB)

There’s definitely something very wrong with the include paths, which is the cause of this error. It’s possibly related to the explicit space in the GEANT 4 part of the path. Is the source code for exampleB1 in C:\Users\Ellie\Desktop\B1?

I would suggest trying the following:

  1. Delete the directory C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build\B1-build just in case having this “build directory under a build directory” pattern is causing an issue.

  2. Create a directory C:\Users\Ellie\Desktop\B1-build in which to build the example

  3. Run CMake in that directory:

    > cmake -DGeant4_DIR="C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build"  C:\Users\Ellie\Desktop\B1
    

    where I’ve assumed the B1 example has been copied out of Geant4 into C:\Users\Ellie\Desktop\B1

  4. Then build as before and see if the error reoccurs

  5. If it does, then it’s almost certainly the space in GEANT 4, so retry the above process, first with:

    > cmake -DGeant4_DIR="C:\Users\Ellie\Desktop\GEANT\ 4\geant4_10_05_p01\geant4_10_05_p01-build"  C:\Users\Ellie\Desktop\B1
    

    and if that still fails

    > cmake -DGeant4_DIR="C:\Users\Ellie\Desktop\GEANT\\ 4\geant4_10_05_p01\geant4_10_05_p01-build"  C:\Users\Ellie\Desktop\B1
    

If after all that it still can’t build, then it may be a bug in the Geant4Config.cmake script that doesn’t handle paths with spaces correctly. Try the above first though and see what happens, and if there are errors please post the logs as before.

I moved B1-build to the desktop and ran CMake successfully. However, the same error as before occurred when I tried building B1. I then tried both variations of setting DGeant4_DIR, but got a new error with CMake, copied below.
Geant4_error.3.txt (975 Bytes)
It was the same error with both \GEANT\ 4 and \GEANT\\ 4.
Thanks!

O.k., I’m able to reproduce this issue and have triaged it as a bug in the handling of spaces in paths in Geant4Config.cmake. We’ll get a fix in for the next patch and release, but in the meantime what you could try is:

  1. Go into C:\Users\Ellie\Desktop\GEANT 4\geant4_10_05_p01\geant4_10_05_p01-build and run

    > cmake -DCMAKE_INSTALL_PREFIX="C:\Users\Ellie\Desktop\geant4_10_05_p01-install" .
    ...
    > cmake --build . --config Release --target install
    

    This should install your Geant4 build under C:\Users\Ellie\Desktop\geant4_10_05_p01-install so no space present.

  2. Re-create the directory C:\Users\Ellie\Desktop\B1-build in which to build the example, and run make again, pointing it to the new install area like so:

    > cmake -DGeant4_DIR="C:\Users\Ellie\Desktop\geant4_10_05_p01-install\lib\Geant4-10.5.1"  C:\Users\Ellie\Desktop\B1
    
  3. Then try building the example there

    > cmake --build .  --verbose --config Release
    

It should hopefully work now!

That worked, thank you so much!