Building exampleB1: binmake.gmk issue

Geant4 Version: 11.2.0
Operating System: Ubuntu 22.04 via WSL 2 / Windows 10
Compiler/Version: 11.4.0
CMake Version: 3.22.1

I got Geant4 installed and am now trying to get a couple apps going including the B1 example. I did the following steps to configure with ccmake and build. Which is where my error with binmake.gmk happens.

# Switch to folder for exampleB1 application.
user@machine:~$ cd /usr/local/share/Geant4/examples/basic/B1

# Create folders for build files and install files.
user@machine:/usr/local/share/Geant4/examples/basic/B1$ sudo mkdir build
user@machine:/usr/local/share/Geant4/examples/basic/B1$ sudo mkdir install

# Change into build folder and configure the build (aka compilation) files.
user@machine:/usr/local/share/Geant4/examples/basic/B1$ cd build
user@machine:/usr/local/share/Geant4/examples/basic/B1/build$ sudo ccmake ..

# Press c for the initial configuration.
# Set the CMAKE_BUILD_TYPE option to Release.
# Set the CMAKE_INSTALL_PREFIX option to the install folder above.
# Press c to check the configuration and produce generation option.
# Press g to generate. If all goes well, should drop back to prompt.

# some how all of the build files ended up in the B1/ folder
# instead of the B1/build/ folder so I ran sudo make from there.

# make (aka compile) the build files.
user@machine:/usr/local/share/Geant4/examples/basic/B1$ sudo make

# This is where I got the following message.
GNUmakefile:16: ../../../config/binmake.gmk: No such file or directory
make: *** No rule to make target '../../../config/binmake.gmk'.  Stop.

based one this thread, I went ahead and sourced the geant4make.sh script and appended it to my .bashrc though it made no difference. Would anyone be able to help me?

I think the CMake and GNUmake based builds have got mixed up a bit. To go back one step, it will be easier and less error prone to copy the example project from the location under /usr/local to somewhere under the home directory. E.g.:

$ cd $HOME
$ cp -R /usr/local/share/Geant4/examples/basic/B1 .
$ cd B1
$ mkdir -p build install
$ cd build
$ cmake ..

That way there’s no need to sudo everything, and which may have caused the problems with where the build files ended up. Running make in the source directory will have caused it to choose the GNUmakefile there in place of the generated Makefile since it’s GNU’s make.

Thanks for the feedback. I am sure I am doing something silly. Coming from the Python world, this compilation workflow is still new to me. Here is what I put into ccmake.

                                                     Page 1 of 1
 CMAKE_BUILD_TYPE                 Release
 CMAKE_INSTALL_PREFIX             /home/ali/geant4/B1/install
 Geant4_DIR                       /usr/local/lib/cmake/Geant4
 PTL_DIR                          /usr/local/lib/cmake/Geant4/PTL
 Qt53DCore_DIR                    /usr/lib/x86_64-linux-gnu/cmake/Qt53DCore
 Qt53DExtras_DIR                  /usr/lib/x86_64-linux-gnu/cmake/Qt53DExtras
 Qt53DInput_DIR                   /usr/lib/x86_64-linux-gnu/cmake/Qt53DInput
 Qt53DLogic_DIR                   /usr/lib/x86_64-linux-gnu/cmake/Qt53DLogic
 Qt53DRender_DIR                  /usr/lib/x86_64-linux-gnu/cmake/Qt53DRender
 Qt5Core_DIR                      /usr/lib/x86_64-linux-gnu/cmake/Qt5Core
 Qt5Gui_DIR                       /usr/lib/x86_64-linux-gnu/cmake/Qt5Gui
 Qt5Network_DIR                   /usr/lib/x86_64-linux-gnu/cmake/Qt5Network
 Qt5OpenGL_DIR                    /usr/lib/x86_64-linux-gnu/cmake/Qt5OpenGL
 Qt5Widgets_DIR                   /usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets
 Qt5_DIR                          /usr/include/x86_64-linux-gnu/qt5
 WITH_GEANT4_UIVIS                ON



CMAKE_BUILD_TYPE: Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel
  ...Keys: [enter] Edit an entry [d] Delete an entry                                                
  CMake Version 3.22.1      [l] Show log output   [c] Configure
      [h] Help              [q] Quit without generating
      [t] Toggle advanced mode (currently off)

Seems like it does configure though it gives me the following warning.

 CMake Warning at /usr/local/lib/cmake/Geant4/Geant4PackageCache.cmake:9 (message):
   Value of 'Qt5_DIR' is already set and does not match value set at Geant4
   build-time
 Call Stack (most recent call first):
   /usr/local/lib/cmake/Geant4/Geant4PackageCache.cmake:24 (geant4_set_and_check_package_variable)
   /usr/local/lib/cmake/Geant4/Geant4Config.cmake:248 (include)
   CMakeLists.txt:13 (find_package)

 Configuring done

I changed the Qt5 directory since with the automatically found choice (under that same cmake folder) gave an error that it could not find Qt5. The location I gave it was found by using the find /usr/ -name "Qt*" command. I went ahead and generated since it said configuring was done. Again, it did not put anything into the build folder. So I had to run make in the B1 folder. And I got the same error as before.

GNUmakefile:16: ../../../config/binmake.gmk: No such file or directory
make: *** No rule to make target '../../../config/binmake.gmk'.  Stop.

Sorry for the delay in replying - one thing to check is if there is a file named CMakeCache.txt and a directory named CMakeFiles in /usr/local/share/Geant4/examples/basic/B1 or the copy of that directory that you made (i.e. they are present alongside the CMakeLists.txt and exampleB1.cc files). If there are, CMake may be picking these up and assuming that’s where the build directory is. If that file/directory are present in the source directory for B1, remove them and try running CMake in the separate build directory again.

Apologies for the delay! I do not want to leave this thread hanging. As it turns out, I had to install GEANT4 on another (actual) Ubuntu computer for a colleague (vs my WSL computer). It went well on that one. Thinking that I must have followed some step incorrectly, I went ahead and re-did it on my computer with WSL Ubuntu. It compiled, installed, and simulated just fine. The only difference is that the actual Ubuntu computer does a better job of displaying many histories (≥ 1000) in the Qt5 window despite older/weaker hardware.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.