Getting Error after completing the build and compilation of example B1

I’ve checked for both the cases. They are fine. But after running these commands in the build folder, this error occur:
CMake Warning:
Ignoring extra path from command line:

“Release”

CMake Error: Unknown argument --config
CMake Error: Run ‘cmake --help’ for all supported options.

I’m getting all these errors in visual Studio after starting from scratch. What is the reason for these errors although I’ve followed the installation guide?

Severity Code Description Project File Line Suppression State
Error CMake Error: File C:/geant4/geant4-install/share/Geant4/examples/extended/electromagnetic/TestEm18/vis.mac does not exist.
Error CMake Error: File C:/geant4/geant4-install/share/Geant4/examples/extended/electromagnetic/TestEm18/TestEm18.in does not exist.
Error CMake Error at extended/CMakeLists.txt:9 (add_subdirectory):
add_subdirectory given source “errorpropagation” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 9
Error CMake Error at extended/CMakeLists.txt:10 (add_subdirectory):
add_subdirectory given source “eventgenerator” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 10
Error CMake Error at extended/CMakeLists.txt:11 (add_subdirectory):
add_subdirectory given source “exoticphysics” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 11
Error CMake Error at extended/CMakeLists.txt:12 (add_subdirectory):
add_subdirectory given source “field” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 12
Error CMake Error at extended/CMakeLists.txt:13 (add_subdirectory):
add_subdirectory given source “g3tog4” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 13
Error CMake Error at extended/CMakeLists.txt:14 (add_subdirectory):
add_subdirectory given source “geometry” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 14
Error CMake Error at extended/CMakeLists.txt:15 (add_subdirectory):
add_subdirectory given source “hadronic” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 15
Error CMake Error at extended/CMakeLists.txt:16 (add_subdirectory):
add_subdirectory given source “medical” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 16
Error CMake Error at extended/CMakeLists.txt:17 (add_subdirectory):
add_subdirectory given source “optical” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 17
Error CMake Error at extended/CMakeLists.txt:18 (add_subdirectory):
add_subdirectory given source “parallel” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 18
Error CMake Error at extended/CMakeLists.txt:19 (add_subdirectory):
add_subdirectory given source “parameterisations” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 19
Error CMake Error at extended/CMakeLists.txt:20 (add_subdirectory):
add_subdirectory given source “persistency” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 20
Error CMake Error at extended/CMakeLists.txt:21 (add_subdirectory):
add_subdirectory given source “physicslists” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 21
Error CMake Error at extended/CMakeLists.txt:22 (add_subdirectory):
add_subdirectory given source “polarisation” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 22
Error CMake Error at extended/CMakeLists.txt:23 (add_subdirectory):
add_subdirectory given source “radioactivedecay” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 23
Error CMake Error at extended/CMakeLists.txt:24 (add_subdirectory):
add_subdirectory given source “runAndEvent” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 24
Error CMake Error at extended/CMakeLists.txt:25 (add_subdirectory):
add_subdirectory given source “visualization” which is not an existing
directory. C:\geant4\geant4-install\share\Geant4\examples\extended/CMakeLists.txt 25
Error CMake Error at extended/electromagnetic/CMakeLists.txt:7 (add_subdirectory):
add_subdirectory given source “TestEm2” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 7
Error CMake Error at extended/electromagnetic/CMakeLists.txt:8 (add_subdirectory):
add_subdirectory given source “TestEm3” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 8
Error CMake Error at extended/electromagnetic/CMakeLists.txt:9 (add_subdirectory):
add_subdirectory given source “TestEm4” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 9
Error CMake Error at extended/electromagnetic/CMakeLists.txt:10 (add_subdirectory):
add_subdirectory given source “TestEm5” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 10
Error CMake Error at extended/electromagnetic/CMakeLists.txt:11 (add_subdirectory):
add_subdirectory given source “TestEm6” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 11
Error CMake Error at extended/electromagnetic/CMakeLists.txt:12 (add_subdirectory):
add_subdirectory given source “TestEm7” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 12
Error CMake Error at extended/electromagnetic/CMakeLists.txt:13 (add_subdirectory):
add_subdirectory given source “TestEm8” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 13
Error CMake Error at extended/electromagnetic/CMakeLists.txt:14 (add_subdirectory):
add_subdirectory given source “TestEm9” which is not an existing directory. C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/CMakeLists.txt 14
Error CMake Error at extended/electromagnetic/TestEm18/CMakeLists.txt:48 (configure_file):
configure_file Problem configuring file TestEm18 C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/TestEm18/CMakeLists.txt 48
Error CMake Error at extended/electromagnetic/TestEm18/CMakeLists.txt:48 (configure_file):
configure_file Problem configuring file TestEm18 C:\geant4\geant4-install\share\Geant4\examples\extended/electromagnetic/TestEm18/CMakeLists.txt 48
Warning CMake Warning (dev) in C:\geant4\geant4-install\share\Geant4\examples\CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a “project(Project)” command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it. C:\geant4\geant4-install\share\Geant4\examples\CMakeLists.txt 1

And with these I’m not getting the output again. Please suggest me something what should I do

Whilst I know you’ve said you followed the Installation Guide, could you post the exact set of cmake commands/arguments you used to build Geant4 and then the application please? The outputs above are odd because:

  • The files listed, e.g. C:/geant4/geant4-install/share/Geant4/examples/extended/electromagnetic/TestEm18/vis.mac should be present in an install, so would indicate something may have gone wrong there.
  • The output would indicate that all the examples are trying to be built. That’s not something that’s generally supported, though even then I wouldn’t expect the errors listed above (hence my question on the exact set of commands/arguments used to help understand what’s going on).

I’ve created a directory geant4 in which I’ve build and installed the application.
CMake Commands I followed are:
Inside the build directory:

cmake -DCMAKE_INSTALL_PREFIX=“C:\geant4\geant4-install” “C:\geant4\geant4-v11.1.0”
cmake -DGEANT4_INSTALL_DATA= ON .
cmake -DGEANT4_USE_OPENGL_WIN32=ON .
cmake -DGEANT4_USE_GDML=ON .
cmake --build . --config Release
cmake --build . --config Release --target install

Then there were some errors so I turned off GDML and reconfigured and reinstalled. And these were the errors in Visual Studio not in Command line.

O.k., those arguments look fine for building Geant4, and just to confirm that the commands:

cmake --build . --config Release
cmake --build . --config Release --target install

when run from the command line do result in a successful build/install? When/how/what for did you open the full Visual Studio application?

I used Developer Command Prompt of visual studio. So In the start I opened Visual Studio and just saw these errors in between but I didn’t do anything with them. I copied them and waited for the process to complete. But again while testing I faced the same problem, that Abort pop up.

and this time I don’t why “.vs” file is present along with build, installed and source files in the main directory

I have to admit I’m a bit lost with what’s going here. I think you should be able to attach files, so could you first post the CMakeCache.txt file from the directory in which you built Geant4 please?

Here it is:

CMakeCache.txt (27.3 KB)

Thanks for the file - this looks fine, and the GEANT4_USE_OPENGL_WIN32:BOOL=ON line is there. Thus the build should have compiled this and installed it. To confirm this, could you post:

  1. the file C:/geant4/geant4-install/lib/cmake/Geant4/Geant4Config.cmake (or any instance of a file named Geant4Config.cmake under C:/geant4/geant4-install)
  2. the CMakeCache.txt file from the directory where you are building the application (i.e. exampleB1)

please?

CMakeCache.txt (27.3 KB)
Geant4Config.txt (31.2 KB)

I’ve converted cmake file to txt file

Thanks, the Geant4Config.cmake file looks fine. The CMakeCache.txt file is however, as far as I can tell, for the build of Geant4, not the example. Could you find and post the one for the build of example B1 please, and also the cmake commands you use to configure example B1?

Sorry for the wrong file. Here is the right one:
CMakeCache.txt (14.9 KB)

I build the example inside the directory

B1/out/build
Commands used by me to configure this are:
cmake -S …/…/ -B .
MSBuild.exe B1.sln
cd Debug
./exampleB1.exe

All I can see that might be affecting things to that something in the example build cache isn’t updated, or building the example in Debug mode is not compatible with the installed Geant4 libraries which are Release mode.

What I’d suggest is to delete entirely the B1/out/build directory and create a new one. Then do:

> cmake -DCMAKE_PREFIX_PATH="C:/geant4/geant4-install"  ../..

and please post the output here. Assuming that’s successful, then run

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

and again, please post the output here.

You can then try running ./Release/exampleB1 and see what happens.

Thanks a lot @bmorgan. I’m getting both the output and visualization now. Can you please explain me the use of these commands for better understanding. I’ve also attached the outputs of the above commands.
output1.txt (1.4 KB)
output2.txt (6.5 KB)

Do I have to proceed like this every time for compiling code in windows?

Thanks for the outputs - these all look fine!

I think what happened in this case, though I cannot be sure is that the build of exampleB1 did not pick up the update you did to the install of the Geant4 libraries to enable the OpenGL driver. In general, there’s no need to go through all of the steps/checks we’ve worked through every time.

However care’s needed when you install a new version of Geant4, or reinstall an existing one with a new feature (like we did here). It is then best to delete and recreate any builds of your end application(s) to guarantee the new Geant4 libraries are picked up and used.

1 Like