Error while running exampleB1.exe

I have already installed Geant4.10.05 with qt 4.8.4 by visual studio 2017 and cmake 3.16.0 on windows 10 education. I also successfully build example B1 and get exampleB1.exe in Release folder. BUT when i run that exe, it come with an error:
ERROR: Can not open a macro file <init_vis.mac>. Set macro path with “/control/macroPath” if needed.
I tried to click macropath under control, and that exe closed automatically. What should I do to solve this problem?!

1 Like

Hello,

If you manually copy the init_vis.mac file ( and the other mac files if there are) in the Release folder (that contains ExempleB1.exe) it should work.

The way it is made assumes that the .mac Geant4 macro file are in the same folder as the compiler executable. It is how it is by default in Linux, but not with Windows Visual Studio (but can be changed, or add a post compile task to copy the .Mac files, but it is just much simpler to manually copy)

Best,
-David

Thank you. But perhaps I got a new problem. I put <init_vis.mac> into the Release folder and running the exe with error message:
ERROR: Can not open a macro file <vis.mac>. Set macro path with “/control/macroPath” if needed.
So I put <vis.mac> into the Release folder. After I did this, I ran exe without the window that the picture show. Just a file <G4History.macro> has been created. Does it work properly?

I think it is not working properly.
You should get the Qt Window with the 3D view. See screenshot:

Maybe your execution is crashing when loading the 3D view? is there anything diplaying on the terminal after “Available UI session types: [ Qt, Win32, GAG, csh ]”
(you can open a terminal first and then navigate to the Release folder and launch exampleB1.exe if you want the terminal not to close automatically after the crash.)

Sorry to disturb you again. I found that the problem is occured with my Qt and I can’t solve it. So I decided to install Qt5 instead of Qt4 because I used to run Qt5 successfully. But another problem is Cmake can’t find Qt5 when I reinstalled Geant4. It shows:
“CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindQt4.cmake:1314 (message):
Found unsuitable Qt version “” from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
cmake/Modules/Geant4InterfaceOptions.cmake:120 (find_package)
cmake/Modules/G4CMakeMain.cmake:64 (include)
CMakeLists.txt:55 (include)”
I found Cmake 3.16.0 only have FindQt3.cmake and FindQt4.cmake. How can I use Qt5 to build Geant4?

I think CMake cannot find your Qt5 installation. You can fix this by adding/updating your CMAKE_PREFIX_PATH in CMake-GUI (create the variable if it is not set yet). Set it to or add something like :
CMAKE_PREFIX_PATH="\Dev\Qt5Dir\lib\cmake" ; it should be the path to where you have the cmake folder in your Qt5 installation.
Good luck !
-David

It may work properly now! Thank you for your advice. Although there are still some problems, they have been solved successfully in the end. This is my result of B1. Does it ok?

It looks how it should be. Congratulations !