Geant4 compiled to .dll getting stuck on G4RunManager initialization

I am using Windows 11. I have compiled Geant4 custom program to a dynamic library (.dll) file so it could be used as a simulation module in other simulation software ( (4.7 KB)). For testing of the .dll file I have created a console app, which imports the library and uses it to print some basic output. ( (871 Bytes))

When running the console app, it gets stuck at the line G4RunManager * runManager = new G4RunManager. The app only outputs Geant4 information and then stops with no error message.

 Geant4 version Name: geant4-10-07-patch-03    (19-November-2021)
                       Copyright : Geant4 Collaboration
                      References : NIM A 506 (2003), 250-303
                                 : IEEE-TNS 53 (2006), 270-278
                                 : NIM A 835 (2016), 186-225
                             WWW :

Note that when I compiled the program to an executable (.exe) file, everything works fine. Could anybody help with this issue?