Message: compilation problems of 4.9.5.p02 on XP/cmake/mingw: #ifdef _WIN32 instead of WIN32 Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Warning compilation problems of 4.9.5.p02 on XP/cmake/mingw: #ifdef _WIN32 instead of WIN32 

Forum: Installation and Configuration
Date: 27 Jun, 2013
From: Mojca Miklavec <Mojca Miklavec>

I'm trying to compile Geant4.9.5.p02 on Windows XP using CMake & MinGW.

(The reason for testing the old version of Geant4 is the desire to eventually compile Gate on it, but there is a high chance that the same problems are present on 4.9.6 - I would be grateful for fixing both if that is the case.)

There might be more obstacles, but the first ones I stumbled into are the following errors:

  [  3%] Building CXX object source/global/CMakeFiles/_G4global-archive.dir/HEPNumerics/src/G4ConvergenceTester.cc.obj
  In file included from C:/Programs/geant4/geant4.9.5.p02-src/source/global/HEPNumerics/include/G4ConvergenceTester.hh:53:0,
                   from C:\Programi\fizika\geant4\geant4.9.5.p02-src\source\global\HEPNumerics\src\G4ConvergenceTester.cc:43:
  C:/Programs/geant4/geant4.9.5.p02-src/source/global/management/include/G4Timer.hh:85:25: fatal error: sys/times.h: No such file or directory
  compilation terminated.
  source\global\CMakeFiles\_G4global-archive.dir\build.make:105: recipe for target 'source/global/CMakeFiles/_G4global-archive.dir/HEPNumerics/src/G4ConvergenceTester.cc.obj' failed
  mingw32-make[2]: *** [source/global/CMakeFiles/_G4global-archive.dir/HEPNumerics/src/G4ConvergenceTester.cc.obj] Error 1
  CMakeFiles\Makefile2:1404: recipe for target 'source/global/CMakeFiles/_G4global-archive.dir/all' failed
  mingw32-make[1]: *** [source/global/CMakeFiles/_G4global-archive.dir/all] Error 2
  Makefile:135: recipe for target 'all' failed
  mingw32-make: *** [all] Error 2

  [  2%] Building CXX object source/analysis/CMakeFiles/_G4analysis-archive.dir/src/G4RootAnalysisManager.cc.obj
  In file included from C:/Programs/geant4/geant4.9.5.p02-src/source/analysis/include/G4RootAnalysisManager.hh:36:0,
                   from C:\Programi\fizika\geant4\geant4.9.5.p02-src\source\analysis\src\G4RootAnalysisManager.cc:30:
  C:/Programs/geant4/geant4.9.5.p02-src/source/analysis/include/tools/wroot/file: In member function 'virtual bool tools::wroot::file::synchronize()':
  C:/Programs/geant4/geant4.9.5.p02-src/source/analysis/include/tools/wroot/file:122:9: error: '::fsync' has not been declared
  In file included from C:/Programs/geant4/geant4.9.5.p02-src/source/global/management/include/G4PhysicalConstants.hh:27:0,
                   from C:/Programs/geant4/geant4.9.5.p02-src/source/global/management/include/globals.hh:71,
                   from C:/Programs/geant4/geant4.9.5.p02-src/source/analysis/include/G4AnalysisVerbose.hh:33,
                   from C:/Programs/geant4/geant4.9.5.p02-src/source/analysis/include/G4VAnalysisManager.hh:33,
                   from C:/Programs/geant4/geant4.9.5.p02-src/source/analysis/include/G4RootAnalysisManager.hh:33,
                   from C:\Programi\fizika\geant4\geant4.9.5.p02-src\source\analysis\src\G4RootAnalysisManager.cc:30:
  C:/Programs/clhep/2.1.3.1-inst/include/CLHEP/Units/PhysicalConstants.h: At global scope:
  C:/Programs/clhep/2.1.3.1-inst/include/CLHEP/Units/PhysicalConstants.h:80:21: warning: 'CLHEP::electron_charge' defined but not used [-Wunused-variable]
  source\analysis\CMakeFiles\_G4analysis-archive.dir\build.make:129: recipe for target 'source/analysis/CMakeFiles/_G4analysis-archive.dir/src/G4RootAnalysisManager.cc.obj' failed
  mingw32-make[2]: *** [source/analysis/CMakeFiles/_G4analysis-archive.dir/src/G4RootAnalysisManager.cc.obj] Error 1
  CMakeFiles\Makefile2:563: recipe for target 'source/analysis/CMakeFiles/_G4analysis-archive.dir/all' failed
  mingw32-make[1]: *** [source/analysis/CMakeFiles/_G4analysis-archive.dir/all] Error 2
  Makefile:135: recipe for target 'all' failed
  mingw32-make: *** [all] Error 2

  [  3%] Building CXX object source/global/CMakeFiles/_G4global-archive.dir/management/src/G4SliceTimer.cc.obj
  In file included from C:\Programi\fizika\geant4\geant4.9.5.p02-src\source\global\management\src\G4SliceTimer.cc:37:0:
  C:/Programs/geant4/geant4.9.5.p02-src/source/global/management/include/G4SliceTimer.hh:86:25: fatal error: sys/times.h: No such file or directory
  compilation terminated.
  source\global\CMakeFiles\_G4global-archive.dir\build.make:801: recipe for target 'source/global/CMakeFiles/_G4global-archive.dir/management/src/G4SliceTimer.cc.obj' failed
  mingw32-make[2]: *** [source/global/CMakeFiles/_G4global-archive.dir/management/src/G4SliceTimer.cc.obj] Error 1
  CMakeFiles\Makefile2:1404: recipe for target 'source/global/CMakeFiles/_G4global-archive.dir/all' failed
  mingw32-make[1]: *** [source/global/CMakeFiles/_G4global-archive.dir/all] Error 2
  Makefile:135: recipe for target 'all' failed
  mingw32-make: *** [all] Error 2

I narrowed the problem down to these minimal patches needed to compile the code:

  --- a/source/analysis/include/tools/wroot/file
  +++ b/source/analysis/include/tools/wroot/file
  @@ -116,7 +116,7 @@ public: //ifile

     virtual bool synchronize(){
       // Synchornize a file's in-core and on-disk states.
  -#ifdef WIN32
  +#ifdef _WIN32
       return true;
   #else
       if (::fsync(m_file) < 0) {
  (END)

  --- a/source/global/management/include/G4Timer.hh
  +++ b/source/global/management/include/G4Timer.hh
  @@ -80,7 +80,7 @@
   #ifndef G4TIMER_HH
   #define G4TIMER_HH

  -#ifndef WIN32
  +#ifndef _WIN32
   #  include <unistd.h>
   #  include <sys/times.h>
   #else
  @@ -103,7 +103,7 @@
      extern "C" {
         extern clock_t times(struct tms *);
      };
  -#endif  /* WIN32 */
  +#endif  /* _WIN32 */

   #include "G4Types.hh"
   #include "G4ios.hh"

  --- a/source/global/management/include/G4SliceTimer.hh
  +++ b/source/global/management/include/G4SliceTimer.hh
  @@ -81,7 +81,7 @@
   #ifndef G4SLICE_TIMER_HH
   #define G4SLICE_TIMER_HH

  -#ifndef WIN32
  +#ifndef _WIN32
   #  include <unistd.h>
   #  include <sys/times.h>
   #else
  @@ -104,7 +104,7 @@
      extern "C" {
         extern clock_t times(struct tms *);
      };
  -#endif  /* WIN32 */
  +#endif  /* _WIN32 */

   #include "G4Types.hh"
   #include "G4ios.hh"
  (END)

but there are more places in the source code where _WIN32 should be used instead of WIN32. I believe that these patches (along with others) shouldn't break Visual Studio (I'm not even sure why/how WIN32 is defined in the first place), but they are absolutely necessary to compile with other compilers.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Warning: Re: compilation problems of 4.9.5.p02 on XP/cmake/mingw: #ifdef _WIN32 instead of WIN32   (Gabriele Cosmo - 28 Jun, 2013)
(_ Question: Re: compilation problems of 4.9.5.p02 on XP/cmake/mingw: #ifdef _WIN32 instead of WIN32   (Mojca Miklavec - 28 Jun, 2013)
(_ Note: Re: compilation problems of 4.9.5.p02 on XP/cmake/mingw: #ifdef _WIN32 instead of WIN32   (Ben Morgan - 01 Jul, 2013)
 Add Message Add Message
to: "compilation problems of 4.9.5.p02 on XP/cmake/mingw: #ifdef _WIN32 instead of WIN32"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]