Problem 2217 - Error in building G4 with MultiThreading on Windows with Qt5 enabled
Summary: Error in building G4 with MultiThreading on Windows with Qt5 enabled
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: cmake (show other problems)
Version: 10.6
Hardware: PC Windows
: P4 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2020-01-23 19:33 CET by Andrea
Modified: 2021-11-04 16:03 CET (History)
1 user (show)

See Also:


Attachments
Screenshot of the terminal with the error (292.76 KB, image/png)
2020-01-23 19:33 CET, Andrea
Details
Screenshot of the terminal with the error of the 2th test (41.81 KB, image/png)
2020-01-29 20:17 CET, Andrea
Details

Note You need to log in before you can comment on or make changes to this problem.
Description Andrea 2020-01-23 19:33:00 CET
Created attachment 601 [details]
Screenshot of the terminal with the error

I compiled G4 with Qt5 with MT flag OFF and all works fine.
If I compile G4 with MT flag ON I obtain an error correlated to Qt during the building:

Here is the red error from the terminal:

G4UIQt.obj : error LNK2019: riferimento al simbolo esterno "protected: static class G4coutDestination * G4coutDestinati
on::masterG4coutDestination" (?masterG4coutDestination@G4coutDestination@@1PEAV1@EA) non risolto nella funzione "public
: __cdecl G4UIQt::G4UIQt(int,char * *)" (??0G4UIQt@@QEAA@HPEAPEAD@Z) [C:\Users\Andrea\Documents\Geant4\Installazione\ge
ant4_10_06MT-build\source\interfaces\G4interfaces.vcxproj]
C:\Users\Andrea\Documents\Geant4\Installazione\geant4_10_06MT-build\BuildProducts\Release\bin\G4interfaces.dll : fatal
error LNK1120: 1 esterni non risolti [C:\Users\Andrea\Documents\Geant4\Installazione\geant4_10_06MT-build\source\interf
aces\G4interfaces.vcxproj]


I use Qt 5.12.6 msvc2017_64
I compile G4 also x64.
Comment 1 Gabriele Cosmo 2020-01-24 08:37:48 CET
With Geant4 10.6, only Visual Studio 2019 is supported (see the release notes).
Please, update your system to Visual Studio 2019.
Comment 2 Andrea 2020-01-24 08:52:10 CET
Hi, 

I'm already on Visual Studio 2019.

"MSCV2017_64" is the Qt version and it the newest one.

Thank you
Comment 3 Gabriele Cosmo 2020-01-29 09:26:27 CET
Thanks for clarifying this.

Can you please trying modify the line of code in:
source/global/management/include/G4coutDestination.hh:94

to the following:
G4GLOB_DLL static G4coutDestination* masterG4coutDestination;

recompile and see if the problem gets fixed?  Thanks
Comment 4 Andrea 2020-01-29 20:16:12 CET
I modified the line of the code as indicated and recompiled Geant4, but the error occurred again.

I have attached another screenshot of the error.

Thank you
Comment 5 Andrea 2020-01-29 20:17:29 CET
Created attachment 604 [details]
Screenshot of the terminal with the error of the 2th test
Comment 6 Gabriele Cosmo 2020-01-30 15:27:17 CET
Thanks for your feedback. Can you try one more attempt and let us know?

1. Modify that same line to:
   G4coutDestination* masterG4coutDestination = nullptr;
2. Remove this line in the source code
   source/global/management/src/G4coutDestination.cc:
   G4coutDestination* G4coutDestination::masterG4coutDestination = 0;

and rebuild.
Comment 7 Andrea 2020-01-31 09:13:53 CET
With the last suggested changes all work fine.
Compilation without errors and also the simulation works.

Thank you
Comment 8 Gabriele Cosmo 2020-02-03 08:48:03 CET
Thanks for the feedback.
The fix will be included in the next patch release.