To compile and run Geant4 under Windows systems, some additional information and tools are required, although the installation produre is similar to that required on a UNIX based system. On Windows, the Cygwin toolset and the Microsoft Visual C++ compiler are used.
Cygwin32 is a UNIX development environment available for Microsoft Windows. You can freely obtain Cygwin32 from Cygwin or Cygwin/X .
We do not support direct use of Visual Studio; i.e. we do not
provide Visual Studio workspace (.dsw) or project (.dsp) files, nor
we do provide makefiles for the nmake application of MS
Visual C++.
We use several of the tools provided by the Cygwin toolset:
make.exe as a make tool
g++.exe as a tool to analyse source file dependencies
and create dependency (.d) files
several other unix tools like cp, mv,
rm, touch, etc.
At the installation of the Cygwin toolset it is therefore required to explicitely select some packages (i.e. gmake, gcc, binutils and tcsh from the "devel" category) in addition to those which are part of the default installation.
For more details on the toolset, please see the documentation
available on the
Cygwin pages
.
The User's Guide has quick start guides and help with
setting up Cygwin with setup.exe.
Links to some installation tips for the Cygwin toolset and also "step by step" installation guides can be found in the section Appendix - Step-by-Step Installation Guides - Build for MS Visual C++ of Geant4 User's Guide - For Application Developers.
The usage of Cygwin32 for the build environment results in a build procedure similar to that on a UNIX system.
The following steps are required to install geant4:
Install Cygwin (see also notes above and additional installation notes for known issues related to the most current version):
We do not depend on any specific feature of the version of Cygwin, so newer versions (or slightly older) are expected to work.
Set the environment for MS Visual C++, i.e. set the paths to
libraries, include files, and executables for MS Visual C++. This
can be done by modifying the start-up batch file
cygwin.bat of Cygwin32 to include all the MSDOS commands
found in the file vcvars32.bat provided in MS Visual C++
(in the VC++ .NET compiler installation directory, and usually
located inside the Common7/Tools directory). This
modification should be done after the installation of the Cygwin
toolset, so that the environment gets properly set at the time of
the invocation of the shell.
Unpack the source code into a directory of your choice.
Start the Cygwin shell from the start menu.
At this point you're ready to install Geant4. If manual
installation is chosen, you must set the necessary environment
variables. There are various ways to do so; for example through a
command file for the Cygwin bash shell. This command file could be
named geant4-setup.sh, and you must execute it with
. geant4-setup.sh
including the leading dot and blank space. You could also have this
as your .bashrc file. The commands in the command file
should be:
# Set G4SYSTEM
export G4SYSTEM=WIN32-VC
#
# Set Path to CLHEP
export CLHEP_BASE_DIR=C:/usr/local
#
# --- Other optional settings
#Turn on verbose to show command used for compilation
#export CPPVERBOSE=1
#
Note, in the example above, CLHEP was installed in
C:/usr/local, therefore include/CLHEP and
lib/CLHEP.lib must be included therein.
Once the environment is correctly set, the libraries are built
using make from the geant4/source directory typing
make from the Cygwin bash shell
prompt.
Examples can be built in the same way as the libraries from
examples/novice/N01, for instance: type make from the
shell prompt.
Note that, depending on which external software is used, there may be some warnings in linking about conflictings libraries. This often seems to be caused by an external library compiled for a different run time environment.
The binary of the example is placed by default into the
geant4/bin/WIN32-VC directory. You may run it either from
this directory or from the examples/novice/N01 directory;
sample input and output files are placed in each of the
examples/novice directories. Some of the examples will
need to read data files, and the place has to be given in
environment variables again similar to the following example:
#
# Environment variables needed to find geant4 data files:
#
# Data for neutron scattering processes,
# distributed in a separate tar file, then placed under data
export G4NEUTRONHPDATA=c:/usr/local/geant4/data/G4NDL
#
# Nuclear Photon evaporation data,
# distributed with the source files under data
export G4LEVELGAMMADATA=c:/usr/local/geant4/data/PhotonEvaporation
#
# Data for radiative decay hadronic processes under data,
# distributed in a separate tar file
export G4RADIOACTIVEDATA=c:/usr/local/geant4/data/RadiativeDecay
#
# Data for low energy electromagnetic processes,
# distributed in a separate tar file, then placed under data
export G4LEDATA=c:/usr/local/geant4/data/G4EMLOW
#
# Data for nuclear shell effects for INCL/ABLA hadronic model,
# distributed in a separate tar file, then placed under data
export G4ABLADATA=c:/usr/local/geant4/data/G4ABLA
#
# Data for measured optical surface reflectance in optical processes,
# distributed in a separate tar file, then placed under data
export G4REALSURFACEDATA=c:/usr/local/geant4/data/RealSurface
#
All compiler and linker options are set in
config/sys/WIN32-VC.gmk. If you require options different
from our choice, you can modify this file.