Installing Geant4 Release 4.9.2.p02 on Windows using Microsoft Visual C++ and Cygwin

 

Installation guides are available for a variety of different Geant4 releases and operating systems.  Be sure to use the appropriate guide for your Geant4 release and system.  The full set of guides can be found at:

http://geant4.slac.stanford.edu/installation

 

Contents:

 

What are the three pieces of software required for building Geant4?

 

Getting and Installing Microsoft Visual C++

 

Getting and Installing Cygwin

 

Getting the Correct Version of Cygwin's make.exe

 

Making Cygwin aware of Microsoft Visual C++

 

Working in Cygwin Windows

 

Six_Quick_Checks to Avoid the Most Common Problems

 

Getting and Installing CLHEP

 

Getting Geant4

 

Getting Data Files

 

Doing the Initial Build

 

Single versus Multi-User Installation

 

Creating the setup script

 

The Geant4 Work Directory

 

Selecting an Example Application

 

Configuring the Environment

 

Building an Example Application

 

Running

 

A Few Notes on ExampleN03

 

How to Go Back and Change Choices from./Configure -build

 

What are the three pieces of software required for building Geant4?

 

Microsoft Visual C++:

Microsoft C++ is the compiler that is recommended for Geant4 on Windows.

 

Cygwin:

Cygwin is a Linux shell environment that runs on top of Windows.

While it is possible to run Geant4 without this (see Norman Graf's notes on this, linked from the Geant4 home page), the officially supported way to run Geant4 on Windows is with Cygwin.

By requiring Cygwin, we obtain a common, Linux-like baseline for all of our users.  This greatly simplifies installation and configuration support.

Cygwin provides essential tools such as the make utility.

Cygwin also provides a C++ compiler, so you may wonder why you also need the Microsoft C++ compiler mentioned above.  The reason is that while the Cygwin compiler does work for Geant4, the Microsoft compiler produces significantly faster-running code.  The Microsoft compiler is therefore the officially supported Geant4 solution.

 

CLHEP:

CLHEP is a set of base libraries that have long provided great functionality for the particle physics community.  They provide things like matrix manipulations, four-vector tools and lists of particle properties.  The Geant4 collaboration has chosen to use these libraries rather than re-invent them.  Please note that while CLHEP and Geant4 both come out of the particle physics communities, they are separate products - the Geant4 collaboration is not responsible for maintenance, distribution or documentation of CLHEP.

 

Getting and Installing Microsoft Visual C++

 

Microsoft Visual C++ is a component of Microsoft Visual Studio.  You can install the entire Microsoft Visual Studio, or you can install just the component that you need, Visual C++.

 

Visual C++ is available in a free, stripped-down version that is entirely adequate for Geant4.  This version is called "Visual C++ 2008 Express Edition with SP1."

 

The free version can be obtained from:

http://www.microsoft.com/express/download/

 

Go there from Internet Explorer rather than some other browser since Internet Explorer can run the installers directly for you.

 

Note: the Microsoft web pages change very often.  If they have changed since the last time this Geant4 installation guide was updated, you may have to look around the Microsoft pages and use some ingenuity to interpret what is now the right thing to do.

 

Find the Visual C++ box on the page, select your language, then click "Download"

 

Click "Run" at the security warning.

 

After the download there will be another security warning.  Again click "Run".

 

At "Welcome to setup", click "Next".

 

At "License Agreement", click "I have read and accept the license terms" and "Next".

 

At "Installation Options", unselect the two options, "Silverlight" and "SQL Server" (unless you want them, but you don't need them for Geant4), then ÔNext".

 

At "Destination Folder", accept the default and click "Install".

It will download and install about 100M of code.

 

Hit "Exit"

 

Getting and Installing Cygwin

 

Install Cygwin by downloading setup.exe from

http://www.cygwin.com/

 

Look for where it says "Install or update now!".

Rather than hitting "Run", hit "Save" and download the setup file to the directory c:\Temp\cygwin

 

The setup.exe is very quick to download, but it is just a utility that facilitates the main download.

The main download is very time consuming.  You are essentially downloading a whole operating system (a Linux emulator) that runs on top of Windows.  Sorry it is so slow.  On the plus side, Cygwin provides lots of useful utilities that you may want to use even without Geant4.

 

When you do the installation, pay close attention to the notes below.  You will be taking the defaults in all but one case, but this one exception is important, where you specify the need to add the development package.  Without this package, Cygwin can only run existing code, not build new code as you must do.

 

If you have ever run Cygwin before on this same computer, the setup program may remember your previous settings rather than the defaults.  Check carefully to make sure all settings are as shown below.  Especially, make sure you get the "Default Text File Type" question right, otherwise you will get almost all the way through the installation procedure, and just at the moment that that you are about to have Geant4 running, you will find that you need to delete everything and back up all the way to here.

 

Run setup.exe

 

At the Security Warning, hit "Run"

 

At "Cygwin Net Release Setup Program", hit "Next"

 

Leave everything set at the defaults for the next few screens, this means:

Installation Type: Install from Internet

Root Directory: c:\cygwin

Install For: All Users

Default Text File Type: Unix / binary

Local Package Directory: c:\Temp\cygwin

Internet Connection: Direct Connection

 

Choose A Download Site (any one will do)

 

User URL: leave blank

 

Select Packages: accept all defaults except

 

For the Developer tools, select Install instead of Default.  Do this by clicking just one time on the circle of arrows next to the word "Devel".  It takes a moment to respond, be patient, eventually the word next to the circle of arrows will change from "Default" to "Install".

 

There are many other useful tools in Cygwin, and you are welcome to include whatever you like, but the defaults plus the "Devel" package is enough for Geant4.  You don't have to decide everything now.  You can come back later and rerun setup.exe to pick up these additional tools.  The setup application does a great job of tracking what you already have so that subsequent running only adds what is new.

 

Select "Next" one more time and the installation will proceed.

 

The download will take a long time (but is worthwhile since Cygwin is a great product).  After the download phase is complete, the installation phase begins automatically.

 

Cygwin will create an icon on your desktop.  Use this to open a Cygwin window.

 

The first time you open a Cygwin window, Cygwin will perform some one time setup (it will say things that start with "Copying skeleton files").  Just let it go ahead.

 

By default, Cygwin will create a window that doesn't have much scroll back capacity and doesn't support cut and paste.  You can greatly improve this as follows:

Right click on the Cygwin icon and select "Properties"

On the "Options" tab:

Change buffer size to the maximum, 999.  This gives you longer command history.

Check "Quick Edit Mode" and "Insert Mode".  This makes ctrl-c, ctrl-v work for cutting and pasting.

On the "Layout" tab:

Change "Screen Buffer SizeÉHeight" to the maximum, 9999.  This gives longer scroll back.

Change "Window Size" if you want to.

Click "OK".

 

Getting the Correct Version of Cygwin's make.exe

 

The latest version of the "make" utility that comes with Cygwin is not compatible with Geant4.  Replace it with appropriate version by opening a Cygwin window and typing:

cd /usr/bin

mv make.exe make_381.exe

wget http://geant4.cern.ch/support/extras/cygwin/make.exe

chmod +x make.exe

 

If you're not familiar with "wget", it's a tool to download files from the web without using a full web browser.  It comes as part of the Cygwin web tools package.

 

Making Cygwin aware of Microsoft Visual C++

 

Modify C:\cygwin\cygwin.bat to contain the following line (you can use an application like Notepad to edit this file - don't use Word since it adds additional invisible characters).

Place this line right under where you see:

chdir C:\cygwin\bin

 

call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"

 

Opening a Cygwin window will now give a message like:

Setting environment for using Microsoft Visual Studio 2008 x86 tools.

 

If you don't see that message when you open a Cygwin window, you do not have Microsoft Visual C++ correctly integrated into your setup.  Stop and sort that out before you proceed.

 

If, for example, you get:

The system cannot find the path specified

The problem is likely just that your particular version of Visual C++ lives in a slightly different directory (Microsoft is constantly changing these things).  Look for a directory that looks roughly like the one mentioned above and that has a vcvars32.bat.  Refer to that directory in your cygwin.bat.

 

Working in Cygwin Windows

 

For all of the following, be sure to work within a Cygwin window.  Do not use any other kind of command window, such as the ones from "Command Prompt" or cmd.exe.

 

Pay close attention to the way you specify the paths to files.  Because paths you enter are used by both Geant4 and Windows tools, you need to enter them exactly right.  Entering them other ways may seem to work, but will get you into trouble at later steps.

* Use only forward slash, never backslash

* Always use full path including C: (or other appropriate drive letter)

* Use no spaces in file or directory names

* Use the correct capitilization

For example, use C:/geant4 but not /geant4 or C:\geant4

 

Cygwin's responses to you will sometimes use its own notation, such as

/cygdrive/c/geant4

but you should not use that notation yourself.  Type everything as in C:/geant4

 

Six Quick Checks to Avoid the Most Common Problems

 

Before you go ahead, open a Cygwin window and run the following checks to make sure your environment is properly configured.  Checking these now can save you a lot of trouble later.

 

 

Check 1: Make sure Cygwin knows about your Microsoft Visual C++

 

When you opened the Cygwin window, did you get a message like:

Setting environment for using Microsoft Visual Studio 2008 x86 tools.

 

If not, review the section above on Making Cygwin aware of Microsoft Visual C++.

 

 

Check 2: Make sure you have make:

 

make is the appropriate command for building code as described below.  Users coming from a Linux background may instead be used to typing gmake.  It can be very hard to remember which of these to type, but if you've done the standard Cygwin installation, only make will be defined.

 

Type:

which make

 

You should get:

/usr/bin/make

 

If you instead get something that starts:

which: no make in ...

it probably means you forgot to ask for the "Devel" part of Cygwin.  The default Cygwin installation contains enough components to run software, but not enough to develop software.  Go back to the above instructions about installing Cygwin, rerun the "setup.exe" utility that you already downloaded, and follow the above instructions about "Devel".  Cygwin does a nice job of remembering what you have already installed and will not make you download everything all over again.

 

 

Check 3: Make sure you have the right version of make:

 

Type:

make -version

 

You should get something that starts with:

GNU Make 3.80

 

If the version is different, review the section above on Getting the Correct Version of Cygwin's make.exe.

 

 

Check 4: Make sure you don't have gmake:

 

Type:

which gmake

 

You should get:

which: no gmake in ...

 

If you instead get something that indicates it has found a copy of gmake, the Geant4 build will not work correctly (a common cause of having gmake is if you have installed MATLAB).  A bug in the Geant4 Configure script will cause the Geant4 build will try to use this gmake instead of the correct make and the build will fail with various strange errors.

 

This issue will be fixed properly in a new version of the Geant4 Configure script, but for now you need to work around the problem as follows.

Locate the copy of gmake.exe (the response you got above will tell you where it is).

Rename this copy of gmake.exe to some other name (any name will do).

When you are done with Geant4's ./Configure -build process, you can restore the name back to gmake.exe.

 

 

Check 5: Make sure you have an appropriate version of bash:

 

If you installed your copy of Cygwin recently (any time since Jan of 2009), you can skip this step.  If your copy of Cygwin is older, check to make sure you didn't get a version with a bad copy of the bash environment.

 

Type:

bash -version

 

You should get a response something like:

GNU bash, version 3.2.48(21)-release (i686-pc-cygwin)

 

If the version number is 3.2.25, you will have a problem.

Versions from 3.1 and earlier are OK, and versions from 3.2.48 are OK, but 3.2.25 is bad.

Replace bash.exe by rerunning Cygwin's setup.exe:

Accept the defaults, or make whatever selections you want, until you get to the screen called "Select Packages".

Click on the plus sign next to "Shells".

Click on the circle icon next to "Bash" until it says the above new version number (or something even newer).

Click Next

Cygwin will update only those selections that you have changed since the last time you ran its setup.

 

 

Check 6: Make Sure you don't have any unwanted Geant4 Environment Variables:

 

Unless you're absolutely sure you are starting from a nice clean system, make sure you don't have any pre-existing Geant4 environment variables.  You can use the "printenv" command to show all variables, and filter this with a "grep" for the string G4 as follows:

From a Cygwin window:

printenv | grep G4

 

If any variables show up, find out what is setting them and remove them.  They might be coming from your Windows environment setup (see notes above about Settings...Control Panel...System) or from your  cybwin.bat file or from some other script that you invoke upon login for some other project.  Take the time now to find the cause and resolve it.

 

Getting and Installing CLHEP

 

Go to the CLHEP source download page:

http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/clhep.html

 

From the "Source" section near the top of the page, select "clhep-2.0.4.2.tgz"

which corresponds to:

http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/distributions/clhep-2.0.4.2.tgz

 

The file is about 3.4MB.

 

Put it into:

C:/CLHEP

 

Depending on your personal settings, Internet Explorer may automatically untar the file, so it may appear as a .tgz file or as a .tar file.

 

From a Cygwin window,

navigate to this directory and unpack the file:

cd C:/CLHEP

tar –zxvf clhep-2.0.4.2.tar

(note that Cygwin includes "tab completion", so you just have to type the first part of the file name and then hit tab).

 

The unpacking process will begin, starting with:

2.0.4.2/

2.0.4.2/CLHEP/

2.0.4.2/CLHEP/CVS/

2.0.4.2/CLHEP/CVS/Root

2.0.4.2/CLHEP/CVS/Repository

 

And ending with:

2.0.4.2/CLHEP/Vector/configure

2.0.4.2/CLHEP/config.guess

2.0.4.2/CLHEP/config.sub

2.0.4.2/CLHEP/Makefile.in

2.0.4.2/CLHEP/configure

 

For the following step, be very careful what you enter for "prefix".

Do NOT forget the two dashes in a row before the word "prefix".

Do NOT use Windows-style path: C:/CLHEP/

Do NOT point at the subdirectory of CLHEP/2.0.4.2 that also happens to be named CLHEP

 

Run configure as follows:

cd 2.0.4.2/CLHEP

./configure --prefix C:/CLHEP/

 

You should get a response that starts with:

checking build system type... i686-pc-cygwin

checking host system type... i686-pc-cygwin

checking target system type... i686-pc-cygwin

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

 

And ends with:

config.status: creating test/exctest4.sh

config.status: creating test/exctestNothrow.sh

config.status: creating test/excDblThrow.sh

config.status: creating Exceptions/defs.h

config.status: executing depfiles commands

 

The complete output from the above command can be found in this same web directory as:

CLHEPConfigure.txt

 

Remember that for the following you use the utility make, not the one called gmake.  The latter is not part of Cygwin, and if you have it at all, it will an incompatible version that you happen to have from some other application such as Matlab.  See notes above about gmake.

 

Run the build process by typing:

make

 

You should get a response that starts with:

Making all in Units

make[1]: Entering directory '/cygdrive/c/CLHEP/2.0.4.2/CLHEP/Units'

Making all in Units

make[2]: Entering directory '/cygdrive/c/CLHEP/2.0.4.2/CLHEP/Units/Units'

make  all-am

 

And ends with:

make[1]: Entering directory `/cygdrive/c/CLHEP/2.0.4.2/CLHEP'

./build-clheplib Units Vector Evaluator GenericFunctions Geometry Random Matrix RandomObjects RefCount Cast Exceptions

rm -f CLHEP-2.0.4.2.lib

liblist=`./getObjectList -shared Units Vector Evaluator GenericFunctions Geometry Random Matrix RandomObjects RefCount Cast Exceptions`; \

lib /NOLOGO /OUT:CLHEP-2.0.4.2.lib $liblist

./build-header

make[1]: Leaving directory `/cygdrive/c/CLHEP/2.0.4.2/CLHEP'

 

The complete output from the above command can be found in this same web directory as:

CLHEPMake.txt

 

If you got a response such as:

checking whether the C++ compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables... configure: error: cannot compute suffix of executables: cannot compile and link

See 'config.log' for more details.

configure: error: /bin/sh './configure' failed for Units

It probably means you used the wrong form of path in

./configure --prefix.

Review the notes above.

 

If you got a response such as:

make[2]: CL: command not found

It probably means you didn't edit your cygwin.bat file properly.

Review the notes above.

 

Move the build  products to their installation area (again, be careful you don't accidentally use gmake - you need to use make):

make install

 

You should get a response that starts with:

Making install in Units

make[1]: Entering directory `/cygdrive/c/CLHEP/2.0.4.2/CLHEP/Units'

Making install in Units

make[2]: Entering directory `/cygdrive/c/CLHEP/2.0.4.2/CLHEP/Units/Units'

make[3]: Entering directory `/cygdrive/c/CLHEP/2.0.4.2/CLHEP/Units/Units'

make[3]: Nothing to be done for `install-exec-am'.

 

And ends with:

else :; fi

 /usr/bin/install -c -m 644 'ClhepVersion.h' 'C:/CLHEP//include/CLHEP/ClhepVersion.h'

make[2]: Nothing to be done for `install-data-am'.

make[2]: Leaving directory `/cygdrive/c/CLHEP/2.0.4.2/CLHEP'

make[1]: Leaving directory `/cygdrive/c/CLHEP/2.0.4.2/CLHEP'

 

The complete output from the above command can be found in this same web directory as:

CLHEPInstall.txt

 

You will now have directories such as:

C:/CLHEP/include

and

C:/CLHEP/lib

 

You're done setting up CLHEP.

 

We do not recommend you run the "make check" command described in the CLHEP documentation unless you really want to.  If you do, note that it will report some errors that you can ignore, such as:

FAIL: testMatrix.sh

FAIL: testInversion.sh

FAIL: testBug6181

 

Much more detailed instructions on installation of CLHEP are available from the CLHEP web site:

http://proj-clhep.web.cern.ch/proj-clhep/INSTALLATION/newCLHEP-install.html

 

Getting Geant4

 

From the Geant4 home page:

http://geant4.web.cern.ch/geant4/

 

Select "Download" from near the top right corner of the page.

 

Select "Zip format", which corresponds to:

http://geant4.web.cern.ch/geant4/support/source/geant4_9_2_p02.zip

 

The file is about 28M.

 

Save it to:

cd C:\Geant4

 

Then use whatever zip extraction tool you like to make the files end up in

C:\Geant4\geant4_9_2_p02

but NOT in:

C:\Geant4\geant4_9_2_p02\geant4_9_2_p02

 

For example, with Windows Extraction Wizard,

you can just right click on the file, select "Extract All",

tell it to extract files to C:\Geant4

(NOT the default that it offers, which is C:\Geant4\geant4_9_2_p02)

and hit "Next".

 

Be patient, the extraction process involves a very large number of files.

 

Getting Data Files

 

Depending on the physics of your particular application, you may need to install additional data files.  These data files can be downloaded separately from the Geant4 source distribution page (the same place where you got Geant4 itself).

 

Create a new folder within C:\Geant4\geant4_9_2_p02 to hold any of these required data files.

C:\Geant4\geant4_9_2_p02\data

 

For now, pick up the "data files for low energy electromagnetic processes":

http://geant4.web.cern.ch/geant4/support/source/G4EMLOW.6.2.tar.gz

 

The file is about 8.0M.

 

Put the file into your new data directory.

 

From a Cygwin window,

navigate to this directory and unpack the file:

cd C:/Geant4/geant4_9_2_p02/data

tar –zxvf G4EMLOW.6.2.tar.gz

 

The unpacking process will begin, starting with:

G4EMLOW6.2/

G4EMLOW6.2/auger/

G4EMLOW6.2/auger/au-tr-pr-10.dat

G4EMLOW6.2/auger/au-tr-pr-100.dat

G4EMLOW6.2/auger/au-tr-pr-11.dat

 

And ending with:

G4EMLOW6.2/tripdata/pp-trip-cs-95.dat

G4EMLOW6.2/tripdata/pp-trip-cs-96.dat

G4EMLOW6.2/tripdata/pp-trip-cs-97.dat

G4EMLOW6.2/tripdata/pp-trip-cs-98.dat

G4EMLOW6.2/tripdata/pp-trip-cs-99.dat

 

Doing the Initial Build

 

TAKE YOUR TIME AT THIS STAGE, DON'T RUSH IT.

Mistakes made at this stage can be very time-consuming to correct.  Slow down.

Maybe get a cup of coffee (or a glass of wine) before you proceed.  Breathe.

 

From a Cygwin window:

cd C:/Geant4/geant4_9_2_p02

./Configure -build

 

You will be asked a series of questions.

In most cases, you can just take the default response (by hitting carriage return).

But pay close attention so that you do not accept the default for certain questions listed below.

 

If you get an error of the form, "bash: ./Configure: No such file or directory",

it probably means you have a bad copy of the Cygwin bash.exe.  See notes on bash above.

 

Along the way you will see a message "Failed to locate one or more of the Geant4 data libraries..."  Don't worry about this.  The additional data libraries are not required for the simple physics in our initial examples.  They can be loaded later as needed.  For now, just accept the default response (by hitting carriage return).

 

When the configure script says:

Could not find CLHEP installed on this system!

Please, specify where CLHEP is installed:

 

First, confirm that you have installed your CLHEP to

C:/CLHEP

 

Make sure you have lib, bin and include subdirectories in C:\CLHEP.

If not, recheck your CLHEP installation.  If so, proceed.

 

Enter: C:/CLHEP

 

Take the default for everything else except:

 

When it asks about:

G4UI_BUILD_WIN32_SESSION

G4UI_USE_WIN32

Enter: y

This tells Geant4 that you want to include the optional Windows GUI.  You don't actually need this, but it has the useful effect of forcing a particular flag to be set that solves a bug in the Windows version of the OpenGL Visualization driver.  This trick will probably not be required in future Geant4 releases.

 

When it asks about:

G4VIS_BUILD_OPENGLWIN32_DRIVER

G4VIS_USE_OPENGLWIN32

Enter: y

This tells Geant4 that you want to include the optional OpenGL Visualization driver.

 

Take the default for everything else.

 

Once all of the questions have been answered, you will be told:

WARNING: the generated configuration file

can be edited if necessary!

You can introduce any change to the configuration file

/cygdrive/c/Geant4/geant4_9_2_p02/.config/bin/WIN32-VC/config.sh before the final installation.

To do so, use a shell escape now (e.g. !vi /cygdrive/c/Geant4/geant4_9_2_p02/.config/bin/WIN32-VC/config.sh).

 

Press [Enter] to start installation or use a shell escape to edit config.sh:

 

At this point, what you have seen in this question and answer session should match what you find in this web directory as:

Geant4Build.txt

 

You are ready to proceed with the build.

Hit Enter.

 

You will then see:

Now starting Geant4 libraries build...

 

On this machine the G4SYSTEM=WIN32-VC

On this machine the G4INSTALL=c:/Geant4/geant4_9_2_p02

On this machine the G4TMP=c:/Geant4/geant4_9_2_p02/tmp

On this machine the G4LIB=c:/Geant4/geant4_9_2_p02/lib

On this machine the G4LEVELGAMMADATA=c:/Geant4/geant4_9_2_p02/data/PhotonEvaporation2.0

On this machine the G4RADIOACTIVEDATA=c:/Geant4/geant4_9_2_p02/data/RadioactiveDecay3.2

On this machine the G4LEDATA=c:/Geant4/geant4_9_2_p02/data/G4EMLOW6.2

On this machine the G4NEUTRONHPDATA=c:/Geant4/geant4_9_2_p02/data/G4NDL3.13

On this machine the G4ABLADATA=c:/Geant4/geant4_9_2_p02/data/G4ABLA3.0

On this machine the CLHEP_BASE_DIR=C:/CLHEP

On this machine the CLHEP_INCLUDE_DIR=C:/CLHEP/include

On this machine the CLHEP_LIB_DIR=C:/CLHEP/lib

On this machine the CLHEP_LIB=CLHEP.lib

On this machine G4UI_NONE is not set - following UIs will be built:

On this machine the G4UI_BUILD_WIN32_SESSION=1

On this machine the G4UI_USE_WIN32=1

On this machine G4VIS_NONE is not set - following drivers will be built:

On this machine the G4VIS_BUILD_OPENGLWIN32_DRIVER=1

On this machine the G4VIS_USE_OPENGLWIN32=1

On this machine the XMFLAGS=

On this machine the XMLIBS=

On this machine the XMFLAGS=

On this machine the XAWFLAGS=

On this machine the XAWLIBS=

On this machine the G4LIB_BUILD_STATIC=1

On this machine the G4LIB_USE_GRANULAR=1

 

Starting build...

 

*************************************************************

 Installation Geant4 version : geant4-09-02-patch-02

 Copyright (C) 1994-2009 Geant4 Collaboration

*************************************************************

Making dependency for file src/G4ios.cc ...

Making dependency for file src/G4coutDestination.cc ...

Making dependency for file src/G4VStateDependent.cc ...

Making dependency for file src/G4VNotifier.cc ...

Making dependency for file src/G4VExceptionHandler.cc ...

Making dependency for file src/G4UnitsTable.cc ...

Making dependency for file src/G4Timer.cc ...

Making dependency for file src/G4StateManager.cc ...

Making dependency for file src/G4SliceTimer.cc ...

Making dependency for file src/G4PhysicsVector.cc ...

Making dependency for file src/G4PhysicsTable.cc ...

Making dependency for file src/G4PhysicsOrderedFreeVector.cc ...

Making dependency for file src/G4PhysicsLogVector.cc ...

Making dependency for file src/G4PhysicsLnVector.cc ...

Making dependency for file src/G4PhysicsLinearVector.cc ...

Making dependency for file src/G4PhysicsFreeVector.cc ...

Making dependency for file src/G4OrderedTable.cc ...

Making dependency for file src/G4LPhysicsFreeVector.cc ...

Making dependency for file src/G4GeometryTolerance.cc ...

Making dependency for file src/G4Exception.cc ...

Making dependency for file src/G4ErrorPropagatorData.cc ...

Making dependency for file src/G4DataVector.cc ...

Making dependency for file src/G4AllocatorPool.cc ...

Compiling G4AllocatorPool.cc ...

G4AllocatorPool.cc

Compiling G4DataVector.cc ...

G4DataVector.cc

Compiling G4ErrorPropagatorData.cc ...

G4ErrorPropagatorData.cc

Compiling G4Exception.cc ...

G4Exception.cc

 

If you get a response such as:

On this machine the G4LIB_BUILD_STATIC=1

On this machine the G4LIB_USE_GRANULAR=1

e:/Geant4/geant4_9_2_p02/config/common.gmk:36: *** target pattern contains no '%'.  Stop.

Starting build...

GNUmakefile:108: *** target pattern contains no '%'.  Stop.

You probably just have the wrong version of the Cygwin make utility. Reread the section above on Getting the Correct Version of Cygwin's make.exe.  Once you have the correct version of make, clean up your failed Geant4 build by removing the tmp, lib and bin directories and redo the ./Configure -build.

 

If you got a response such as:

make[2]: CL: command not found

It probably means you didn't edit your cygwin.bat file properly.

Review the notes above.

 

If you get a response such as:

process_begin: CreateProcess(NULL, "", ...) failed.

followed by a set of lines such as:

/usr/bin/sh: c:/Program: No such file or directory

It may be that you have the Matlab gmake problem.  See notes above.

 

If you get a response such as:

The syntax of the command is incorrect.

The syntax of the command is incorrect.

'[' is not recognized as an internal or external command,

operable program or batch file.

'[' is not recognized as an internal or external command,

followed by a set of lines such as:

The system cannot find the path specified.

c:\Program Files\MATLAB\R2007a\bin\win32\gmake.exe: *** [banner

It may be that you have the Matlab gmake problem.  See notes above.

 

Once you see any lines like:

Compiling G4AllocatorPool.cc ...

with no errors,

the compilation is successfully under way.

 

Adjust your machine's power management properties so that it doesn't go to sleep, and then walk away for a long long time.  Wait, and wait, and wait, for the initial compilation to run.

 

The same information that is showing on the console is also being written to a log file so that you can review it later if necessary.  The information will appear in:

C:/Geant4/geant4_9_2_p02/.config/bin/WIN32=VC

 

An example of how this log file should look can be found in this same web directory as:

Geant4Make.txt

 

Eventually, you will see messages stating that libname.map has been built, then you will see messages about successful completion:

Libmap stage. Searching for GNUmakefiles and sorting ...

Weeding out paths and files ...

Making libname.map starter file ...

Making libname.map ...

  Reading library name map file...

  Reading dependency files...

  Checking for circular dependencies...

  Reordering according to dependencies...

  Writing new library map file...

Libraries installation completed !

 

####################################################

# Your Geant4 installation seems to be successful!

# To be sure please have a look into the log file:

# /cygdrive/c/Geant4/geant4_9_2_p02/.config/bin/WIN32-VC/g4make.log

####################################################

 

If you get a response such as:

Libmap stage. Searching for GNUmakefiles and sorting ...

Weeding out paths and files ...

: No such file or directoryfile

: No such file or directoryr/GNUmakefile

: No such file or directoryGNUmakefile

: No such file or directoryement/GNUmakefile

: No such file or directorying/GNUmakefile

Making libname.map ...

  Reading library name map file...

  ERROR: "source/<unique-sub-path>/GNUmakefile" expected.

make[1]: *** [libmap] Error 1

make: *** [all] Error 2

you probably selected the wrong "Default Text File Type" when you did the Cygwin installation. 

Rerun Cygwin's setup.exe and see what it shows for Default Text File Type.  It should be Unix /Binary.  If it isn't, then you must have had it wrong last time.  Correct that, complete the Cygwin setup, then delete your CLHEP and Geant4 and start over.

 

If you get a response that includes:

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\utility(54) : error C2079: 'std::pair<_Ty1,_Ty2>::second' uses undefined class 'G4AttDef'

        with

        [

            _Ty1=const G4String,

            _Ty2=G4AttDef

        ]

É        h:/geant4/geant4_9_2_p02/source/graphics_reps/include\G4AttHolder.hh(75) : see reference to class template instantiation 'std::vector<_Ty>' being compiled

        with

        [

            _Ty=const std::map<G4String,G4AttDef> *

        ]

make: *** [c:/geant4/tmp/WIN32-VC/G4vis_management/G4VSceneHandler.o] Error 2

you probably have a very old copy of Visual Studio and forgot to include the "SP1" patch.

Update Visual Studio (at least add the SP1 patch), delete your Geant4 lib, bin and tmp and try again.

 

If you had needed to rename some other application's gmake.exe before your initial ./Configure -build, you can safely restore that gmake.exe now.

 

Single versus Multi-User Installation

 

The above instructions assumed you were doing a single-user installation.  They had you keep all of the build products in the same area as your CLHEP and Geant4 source.  Note however that both of these packages support standard multi-user installation processes.

 

For CLHEP, just specify a different value for "--prefix".

 

When Geant4's ./Configure -build asks you to "Specify the path where Geant4 libraries and source files should be installed", specify the area you want the code to eventually be installed.

 

When Geant4's ./Configure -build asks you about the CLHEP library, be sure to specify the same location that you specified during the CLHEP installation.

 

After you finish the ./Configure -build, issue an additional command to copy the libraries and header files to the installation area:

./Configure -install.

 

Creating the setup script

 

The configure process has set up some environment variables that you will want to have in future sessions.  Have configure save you an environment setup script for future use by typing:

./Configure

(that was with no options, as opposed to ./Configure -build that you typed earlier).

 

You will see the following:

                --- Geant4 Toolkit Installation  ---

                  (setting environments for USER )

 

---------------------------------------------------

The Geant4 toolkit installation was found.

The files env.[c]sh will be copied to your current directory.

For setting Geant4 environments you should make:

 

source env.csh

or

. env.sh

 

It will also check G4WORKDIR setting and set it to

your HOME if needed.

You can use these files also for further modifications

(adding your own environments).

---------------------------------------------------

 

Your directory C:/Geant4/geant4_9_2_p02 will now contain two scripts:

env.sh

and

env.csh

 

The Geant4 Work Directory

 

You have now built the Geant4 toolkit.  If you have learned a little about Geant4, you will know that Geant4 is not an application but rather a toolkit from which you can build any number of applications.  So before you can test Geant4, you need an example application.

 

You should create a new directory, outside of your Geant4 installation area, where you will keep your example applications.  This separation of spaces will help you avoid accidentally messing up your main Geant4 installation and will insure that if you eventually update your main Geant4 installation (for example when a newer Geant4 release is available), your personal application work will not be disturbed.

 

Create a new directory for your work, and designate it as your G4WORKDIR.

 

For example, if you want your work to be in C:/g4work:

export G4WORKDIR=C:/g4work

 

Selecting an Example Application

 

You can try any of the Geant4 examples.  Some suggested starting points are any of the Novice examples

C:/Geant4/geant4_9_2_p02/examples/novice

or a more complex example

C:/Geant4/geant4_9_2_p02/examples/extended/analysis/A01

 

Each example is described in a detailed README it the example's top level directory.

 

Don't start with exampleN03.  It has some peculiarities on Windows that are discussed later in this section.  Pick some other example for now.

 

Whichever example you choose, copy it to your Geant4 work directory.

For example, you might end up with:

C:/g4work/A01

 

Configuring the Environment

 

Note that this step needs to be redone any time you start a fresh Cygwin window.

 

Type:

export G4WORKDIR=C:/g4work

source C:/Geant4/geant4_9_2_p02/env.sh

 

It will respond:

On this machine the G4SYSTEM=WIN32-VC

On this machine the G4INSTALL=c:/Geant4/geant4_9_2_p02

On this machine the G4LIB=c:/Geant4/geant4_9_2_p02/lib

On this machine the G4LEVELGAMMADATA=c:/Geant4/geant4_9_2_p02/data/PhotonEvaporation2.0

On this machine the G4RADIOACTIVEDATA=c:/Geant4/geant4_9_2_p02/data/RadioactiveDecay3.2

On this machine the G4LEDATA=c:/Geant4/geant4_9_2_p02/data/G4EMLOW6.2

On this machine the G4NEUTRONHPDATA=c:/Geant4/geant4_9_2_p02/data/G4NDL3.13

On this machine the G4ABLADATA=c:/Geant4/geant4_9_2_p02/data/G4ABLA3.0

On this machine the CLHEP_BASE_DIR=C:/CLHEP

On this machine the CLHEP_INCLUDE_DIR=C:/CLHEP/include

On this machine the CLHEP_LIB_DIR=C:/CLHEP/lib

On this machine the CLHEP_LIB=CLHEP.lib

On this machine the G4UI_BUILD_WIN32_SESSION=1

On this machine the G4UI_USE_WIN32=1

On this machine the G4VIS_BUILD_OPENGLWIN32_DRIVER=1

On this machine the G4VIS_USE_OPENGLWIN32=1

On this machine the XMFLAGS=

On this machine the XMLIBS=

On this machine the XMFLAGS=

On this machine the XAWFLAGS=

On this machine the XAWLIBS=

On this machine the G4LIB_BUILD_STATIC=1

On this machine the G4LIB_USE_GRANULAR=1

 

Be sure not to accidentally use the other Linux forms of this command:

source C:/Geant4/geant4_9_2_p02/env.csh

or

cd C:/Geant4/geant4_9_2_p02/

./env.sh

Neither of these will give correct results in this Cygwin environment.

 

A further note about the environment setup scripts:

The env scripts do not set every environment variable that could be used by Geant4.  They only set those variables that you had declared to non-default values in the configure process.  This works fine because any variable that Geant4 does not find is assumed to be default.  But if you are also setting some of your Geant4 environment variables elsewhere, such as in your Windows environment setup, or in your cygwin.bat file, you can end up with inconsistent results.  That is why you were strongly advised to make sure you had no pre-existing Geant4 variables set before you began the Geant4 build.

 

Building an Example Application

 

Did you "Configure the Environment" as described above?  Remember that you need to do this every time you start a new Cygwin window.

 

Build your example by typing, the following.  Be sure to use make rather than gmake.

cd $G4WORKDIR/A01

make

 

You will see output beginning with:

Making dependency for file A01app.cc ...

Making dependency for file src/A01Trajectory.cc ...

Making dependency for file src/A01PrimaryGeneratorMessenger.cc ...

Making dependency for file src/A01PrimaryGeneratorAction.cc ...

Making dependency for file src/A01PhysicsList.cc ...

 

And ending with:

Compiling A01app.cc ...

A01app.cc

Using granular libraries ...

Linking A01app ...

... Done!

 

The complete output from the above command can be found in this same web directory as:

A01Make.txt

 

If you get an error such as:

c:\g4work\A01\src\A01AnalysisManager.cc : fatal error C1083: Cannot open compiler generated file: '/cygdrive/c/g4work/tmp/WIN32VC/A01app/A01AnalysisManager.o':

 No such file or directory

make: *** [/cygdrive/c/g4work/tmp/WIN32VC/A01app/A01AnalysisManager.o] Error 1

it probably means you used the wrong form of the work directory path when you defined your G4WORKDIR variable.  You used a form like "/cygdrive/c/g4work" when you need a form like "C:/g4work".  Wipe out your A01 directory, redefine G4WORKDIR and have another try.

 

If the build is successful, you will see the completed application file in your $G4WORKDIR directory such as:

$G4WORKDIR/bin/WIN32-VC/A01app.exe

 

Running

 

As always, if this is a fresh Cygwin window, configure it for Geant4 by typing:

export G4WORKDIR=C:/g4work

source C:/Geant4/geant4_9_2_p02/env.sh

 

To run your example, cd to the example's top level directory, such as:

cd $G4WORKDIR/A01

 

And from there, run the newly created executable:

$G4WORKDIR/bin/WIN32-VC/A01app

 

You will see a response that starts with:

*************************************************************

 Geant4 version Name: geant4-09-02-patch-02    (28-August-2009)

                      Copyright : Geant4 Collaboration

                      Reference : NIM A 506 (2003), 250-303

                            WWW : http://cern.ch/geant4

*************************************************************

 

Visualization Manager instantiating...

Visualization Manager initialising...

Registering graphics systems...

 

You have successfully registered the following graphics systems.

Current available graphics systems are:

  ASCIITree (ATree)

  DAWNFILE (DAWNFILE)

  G4HepRep (HepRepXML)

  G4HepRepFile (HepRepFile)

  RayTracer (RayTracer)

  VRML1FILE (VRML1FILE)

  VRML2FILE (VRML2FILE)

  OpenGLImmediateWin32 (OGLIWin32)

  OpenGLStoredWin32 (OGLSWin32)

 

And ends with:

    EMcalorimeterPhysical[0] EMcalorimeterLogical 1 CsI

      cellPhysical[-1] cellLogical 0 CsI /EMcalorimeter

    HadCalorimeterPhysical[0] HadCalorimeterLogical 1 Lead

      HadCalColumnPhysical[-1] HadCalColumnLogical 1 Lead

        HadCalCellPhysical[-1] HadCalCellLogical 1 Lead

          HadCalLayerPhysical[-1] HadCalLayerLogical 1 Lead

            HadCalScintiPhysical[0] HadCalScintiLogical 0 Scintillator /HadCalorimeter

Idle>

 

The complete output from the above command can be found in this same web directory as:

A01Run.txt

 

Make sure your output included a mention of the graphics systems:

  OpenGLImmediateWin32 (OGLIWin32)

  OpenGLStoredWin32 (OGLSWin32)

 

If those didn't show up, you have missed something in the above instructions.

Did you correctly answered the questions about OpenGL in the ./Configure -build procedure?

Did you get error messages during that procedure?

Did you follow the instructions in the above section, "Creating the setup script"?

Did you follow the instructions above about "As always, if this is a fresh Cygwin window, configure it for Geant4 by typing..."?

 

If you still can't figure out why you don't have OpenGL, you can still proceed, but you will have to use some other graphics driver.  See some notes a little later in this document about how to use the HepRepFile driver.

 

From here, we'll assume you have OpenGL successfully loaded.

 

From the idle prompt, visualize the example by typing the following:

/vis/open OGLSWin32

/vis/drawVolume

/vis/viewer/flush

 

An OpenGL window will appear and the example geometry will be drawn, as in:

 

To add trajectories and hits to the visualization, and then run an event:

/vis/scene/add/trajectories

/vis/scene/add/hits

/run/beamOn 1

 

You will then see something like:

 

When you are finished with your Geant4 session, just type:

exit

 

For more details on using OpenGL for Geant4, see:

http://geant4.slac.stanford.edu/Presentations/vis/G4OpenGLTutorial/G4OpenGLTutorial.html

 

Here's another example.  This one makes output go to a HepRep file, suitable for viewing in the HepRApp HepRep Browser:

$G4WORKDIR/bin/WIN32-VC/A01app

/vis/open HepRepFile

/vis/drawVolume

/vis/viewer/flush

/vis/scene/add/trajectories

/vis/scene/add/hits

/run/beamOn 1

 

For more details on using HepRApp for Geant4, see:

http://geant4.slac.stanford.edu/Presentations/vis/G4HepRAppTutorial/G4HepRAppTutorial.html

 

Note: HepRApp and Geant4 do not have to run on the same machine.  You can copy the .heprep file from the Geant4 machine to the machine with HepRApp, or you can simply make the .heprep file visible from the web, and let HepRApp pick it up via the url.

Also note that the .heprep file can be zipped to about 5 percent of original size and HepRApp can then read in the zipped version (you don't need to unzip the file).

 

You now have Geant4 installed and have demonstrated a few examples using two different visualization systems.

 

A few notes on ExampleN03

 

As mentioned earlier, for users on Windows, it is best not to start with Example N03 because it has some peculiarities.

To use this exampleN03 on Windows, you need to edit two files before you build the example.

 

Edit: exampleN03.cc

To comment out or delete the three lines:

#elif defined(G4UI_USE_WIN32)

session = new G4UIWin32()

UI->ApplyCommand("/control/execute visTutor/gui.mac");

 

Edit: vis.mac

To replace:

/vis/open OGLIX

with

/vis/open OGLSWin32

 

Without these edits, the example will attempt to use a special user interface that we don't want to get into in this exercise.  And it will fail anyway, because it will try to start right off running a visualization macro that opens a non-windows version of OpenGL.

But with the above two edits, the example can be used on Windows just like all of the other examples.

 

How to go back and change choices from./Configure -build

 

You can go back and re-run Geant4's ./Configure -build procedure at any time to change various options.  In general, this will not force a complete recompilation but will only rebuild those libraries that have changes.

 

Make sure to run ./Configure -build  in a fresh session, one that doesn't have the G4WORKDIR environment variable set.  Otherwise this difference between your original build environment and your new one will trigger a whole new Geant4 build in a whole new place.

 

After the build, do  ./Configure (the version with no arguments that creates the env.sh and env.csh files) and, if you are doing a multi-user installation, ./Configure -install

 

Remember that if you had needed to rename some other application's gmake.exe before your initial ./Configure -build, you will need to do that again now.

 

Also note that even though you successfully rebuild Geant4, your user application will not take advantage of the change unless you explicitly tell it to do so.  The standard way to do this is to update the time stamp of your application's main class before you rebuild the application.  For example, use the "touch" command:

export G4WORKDIR=C:/g4work

source C:/Geant4/geant4_9_2_p02/env.sh

cd $G4WORKDIR/A01

touch A01app.cc

make

 

 

I hope these instructions have been helpful.

If you find any problems or can suggest corrections, please let me know.

 

Joseph Perl

SLAC Geant4 Team

3 September 2009