Installing Geant4 Release 4.8.0.p01 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++ and Microsoft Platform SDK

 

Getting and Installing Cygwin

 

Getting the Correct Version of Cygwin's make.exe

 

Making Cygwin aware of Microsoft Visual C++ and Microsoft Platform SDK

 

Getting and Installing CLHEP

 

Getting Geant4

 

Getting Data Files

 

Doing the Initial Build

 

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

 

Single versus Multi-User Installation

 

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

 

Microsoft Visual C++ and Microsoft Platform SDK:

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

When you install this, you have the option of whether or not to also take Microsoft Platform SDK.  The answer is yes, you need SDK.  Without it, you can make something called a Microsoft .NET application, but you cannot actually make a Windows application (which is what you need for Geant4).

 

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 and four-vector tools.  The Geant4 collaboration has chosen to use these libraries rather than re-invent these wheels.  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++ and Microsoft Platform SDK:

 

There are basically two ways you can obtain it.

You can install the entire Microsoft Visual Studio.NET, 2003 or 2005.

Or you can install just the two components that you need, Visual C++ 2005 and the Microsoft SDK.

These two pieces are available in a stripped-down version that is free for one year and is entirely adequate for Geant4 compilation.  This version is called "Visual C++ Express Edition."

 

The free version can be obtained from:

http://msdn.microsoft.com/vstudio/express/visualc/

 

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

 

Click "Download Now" from over on the right.

The download is about 90MB.

 

Four steps are shown there:

 

1. Uninstall beta versions:

You probably don't need this.

 

2. Download and install:

Click "Run" at both security warnings.

 

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

 

At "License Agreement", click "accept" and "Next".

 

At "Installation Options", unselect "Graphical IDE" (unless you want it, but you don't need it for Geant4), then ÔNext".

 

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

It will download and install two items, "Microsoft .NET Framework 2.0" and "Visual C++ 2005 Express Edition".

 

3. Register:

Not necessary.

 

4: Install the Platform SDK:

Yes, you need this (see comments above).

 

When you click "Install" on this page, it will take you to another page that says "Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK".

 

Click on "Platform SDK" in Step 2.

This will take you to a page that says "Windows Server 2003 SP1 Platform SDK Web Install".

 

Scroll down almost to the bottom.

 

Where it says "Files in This Download", click on "PSDK-x86.exe" (unless you think a different option is more appropriate for your CPU).

 

Click "Run" at both security warnings.

 

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

 

At "License Agreement", click "accept" and "Next".

 

At "User Information", Enter name and click "Next".

 

At "Select an Installation Type", click "Custom" and "Next".

 

At "Select and Installation Location", accept the default and click "Next".

 

At "Custom Installation Tips", click "Next".

 

Change all of the pull down menus on the left side to X.

 

Expand "Microsoft Windows Core SDK"

 

Change the pull down menu next to "Build Environment (x86 32-bit)" to "Entire feature will be installed on local hard drive"

 

Click "Next"

 

At "Begin Installation", click "Next".

It will download and install a bunch of stuff and take a long time.

 

After that is done, you can ignore the rest of that "Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK" page.  Steps 3, 4 and 5 on that page are not necessary for Geant4.

 

If, instead, you select "Typical" installation, it will also work but it will take much much longer to install and will take about 1GB of disk space.

 

Getting and Installing Cygwin

 

Install Cygwin by downloading setup.exe from

http://www.cygwin.com/

 

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

Download the setup file to the directory c:\Temp\cygwin

and then run setup.exe.

 

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 extra 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 not be taking simply the default installation, but will instead be asking for extra, non-default, pieces, specifically the "Devel" package.

 

And 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.

 

Select options as follows:

 

Choose A Download Source: Install from Internet

 

Root Directory: c:\cygwin

 

Install For: All Users

 

Default Text File Type: Unix / binary

(This is a very important distinction.  The other option, DOS, no longer works for Geant4).

 

Local Package Directory: c:\Temp\cygwin

 

Select Your 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".

 

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.  When you are finished, you will find that Cygwin has been installed to c:\cygwin.

 

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.  Just let it go ahead (Starts with "Copying skeleton files").

 

By default, Cygwin will create a window that doesn't have much scroll back capacity.

You can greatly improve this as follows:

Right click on the Cygwin icon.

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".

At "Apply Properties to Shortcut", select "Modify shortcut that started this window"

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.  You must replace this version (make 3.81-1) with the previous version (make 3.80-1) by downloading the following file:

http://geant4.slac.stanford.edu/tutorial/installation/extras/cygwin/make.exe

 

to your Cygwin binaries directory:

c:\cygwin\bin

 

Making Cygwin aware of Microsoft Visual C++ and Microsoft Platform SDK:

 

Modify C:\cygwin\cygwin.bat to contain the following lines (you can use an application like Notepad to edit this file).

Place these lines right under where you see:

chdir C:\cygwin\bin

 

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

call "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\SetEnv.cmd"

 

Opening a Cygwin window will now give a message like:

Setting environment for using Microsoft Visual Studio 2005 x86 tools.

Attempting to detect a Microsoft Visual Studio installation

Targeting Windows XP 32 DEBUG

 

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

 

Getting and Installing CLHEP

 

Go to the CLHEP source download page:

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

 

Select "clhep-1.9.2.2.tgz"

which corresponds to:

http://cern.ch/clhep/clhep-1.9.2.2.tgz

 

The file is about 5MB.

 

Put it into:

c:/CLHEP

 

From a Cygwin window,

navigate to this directory and unpack the file:

cd c:/CLHEP

tar –zxvf clhep-1.9.2.2.tgz

(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:

1.9.2.2/CLHEP/

1.9.2.2/CLHEP/CVS/

1.9.2.2/CLHEP/CVS/Root

1.9.2.2/CLHEP/CVS/Repository

1.9.2.2/CLHEP/CVS/Entries

 

And ending with:

1.9.2.2/CLHEP/install-sh

1.9.2.2/CLHEP/config.guess

1.9.2.2/CLHEP/config.sub

1.9.2.2/CLHEP/Makefile.in

1.9.2.2/CLHEP/configure

 

Now navigate into the unpacked directory and begin the configuration process:

cd 1.9.2.2/CLHEP

 

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/1.9.2.2 that also happens to be named CLHEP Run configure as follows:

./configure --prefix /cygdrive/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

 

Run the build process:

make

 

You should get a response that starts with:

Making all in config

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

Making all in config

make[2]: Entering directory `/cygdrive/c/CLHEP/1.9.2.2/CLHEP/config/config'

make  all-am

 

And ends with:

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

./build-clheplib config Units Vector Evaluator GenericFunctions Geometry Random Matrix RandomObjects HepPDT HepMC StdHep RefCount Cast Exceptions`; \

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

DMFactory.obj : warning LNK4221: no public symbols found; archive member will be inaccessible

make[1]: Leaving directory `/cygdrive/c/CLHEP/1.9.2.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 that "make" was an unknown command, it is likely that you forgot to ask for the "Devel" part of Cygwin.  The default Cygwin installation does not include several of the tools that you will need.  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.

 

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.

 

Move the build  products to their installation area:

make install

 

You should get a response that starts with:

Making install in config

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

Making install in config

make[2]: Entering directory `/cygdrive/c/CLHEP/1.9.2.2/CLHEP/config/config'

make[3]: Entering directory `/cygdrive/c/CLHEP/1.9.2.2/CLHEP/config/config'

 

And ends with:

test -z "C:/CLHEP//lib" || mkdir -p -- "C:/CLHEP//lib"

 /usr/bin/install -c 'CLHEP-1.9.2.2.lib' 'C:/CLHEP//lib/CLHEP-1.9.2.2.lib'

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

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

make[1]: Leaving directory `/cygdrive/c/CLHEP/1.9.2.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:

~/CLHEP/include

and

~/CLHEP/lib

 

You're done setting up CLHEP.

 

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 top of the Geant4 home page:

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

 

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

 

Assuming You Have a Zip Utility

 

Assuming you have a utility to open "zip" format files, such as the Windows Extraction Wizard, WinZip or Alladin Expander,

you should then select "Zip format",

which corresponds to:

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

 

The file is about 22M.

 

Save it to:

cd c:/Geant4

 

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

c:\Geant4\geant4_8_0_p01

but NOT in:

c:\Geant4\geant4_8_0_p01\geant4_8_0_p01

 

For example, if you have the 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_8_0_p01)

and hit "Next".

 

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

 

If You Don't Have a Zip Utility

 

In the unlikely chance that you don't have a utility to open "zip" format files,

you can instead select "Unix tar format, compressed using gzip"

which corresponds to:

http://geant4.web.cern.ch/geant4/support/source/geant4.8.0.p01.tar.gz

 

The file is about 14M.

 

Save it to:

cd c:/Geant4

 

From a Cygwin window,

navigate to this directory and unpack the file:

cd c:/Geant4

tar –zxvf geant4.8.0.p01.tar.gz

 

The unpacking process will begin, starting with:

geant4.8.0.p01/

geant4.8.0.p01/ReleaseNotes/

geant4.8.0.p01/ReleaseNotes/Patch4.4.0-1.txt

geant4.8.0.p01/ReleaseNotes/Patch4.4.0-2.txt

geant4.8.0.p01/ReleaseNotes/Patch4.4.1-1.txt

 

And ending with:

geant4.8.0.p01/source/visualization/modeling/src/G4TrajectoryDrawByCharge.cc

geant4.8.0.p01/source/visualization/modeling/src/G4TrajectoryDrawByParticleID.cc

geant4.8.0.p01/source/visualization/modeling/src/G4TrajectoryDrawerUtils.cc

geant4.8.0.p01/source/visualization/modeling/src/G4TrajectoryModelFactories.cc

geant4.8.0.p01/source/visualization/modeling/src/G4VModel.cc


From here on, we'll show how things look if you had used the zip file.

 

If you had instead used the gzip file, things will still work, but the file names you actually see and the strings you will have to type will have periods, ".", where the file names in our example printouts below have underscores, "_",

(so, for example, where we show: geant4_8_0_p01, you will have geant4.8.0.p01).

 

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_8_0_p01 to hold any of these required data files.

c:\Geant4\geant4_8_0_p01\data

 

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

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

 

The file is about 7.6M.

 

Put the file into your new data directory.

 

From a Cygwin window,

navigate to this directory and unpack the file:

cd c:/Geant4/geant4_8_0_p01/data

tar –zxvf G4EMLOW.3.0.tar.gz

 

The unpacking process will begin, starting with:

G4EMLOW3.0/

G4EMLOW3.0/README

G4EMLOW3.0/auger/

G4EMLOW3.0/auger/au-tr-pr-10.dat

G4EMLOW3.0/auger/au-tr-pr-11.dat

 

And ending with:

G4EMLOW3.0/tripdata/pp-trip-cs-96.dat

G4EMLOW3.0/tripdata/pp-trip-cs-97.dat

G4EMLOW3.0/tripdata/pp-trip-cs-98.dat

G4EMLOW3.0/tripdata/pp-trip-cs-99.dat

G4EMLOW3.0/tripdata/pp-trip-cs-9.dat

 

Before you proceed, you need to replace one file in the unpacked source code.

The OpenGL viewer for Windows is flawed in this release.

Replace the file:

c:/Geant4/geant4_8_0_p01/source/visualization/OpenGL/src/G4OpenGLWin32Viewer.cc

with the version that you find in this web directory as:

G4OpenGLWin32Viewer.cc

 

From a file browser, double check that the new file really ws installed in the correct location and with the correct file extension (.cc).  Some web browsers quietly tack a ".txt" on the end of the file when they download it, and this would leave the old, defective G4OpenGLWin32Viewer.cc in place.

 

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.

 

Also, make sure you replaced the flawed copy of G4OpenGLWin32Viewer.cc as described at the end of the previous section.

 

Finally, 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 "set" 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 c:/Cygwin/cybwin.bat, from your Windows environment variable setup 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.

 

From a Cygwin window:

cd c:/Geant4/geant4_8_0_p01

./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 the following questions:

 

When it says:

Please, specify default directory where ALL the Geant4 data is installed:

Accept the default.

 

But at the next question, when it says almost but not quite the same thing:

Please, specify default directory where the Geant4 data is installed:

Enter: 1

This tells it that you are going to make a correction to the location of the first data file.

This is necessary due to a bug in this version of the configuration script.

 

It will then ask:

Where is Geant4 PhotonEvaporation data installed?

Enter something like: c:/geant4/geant4_8_0_p01/data/PhotonEvaporation2.0

That is, give it what it had suggested for the default but add on a "2.0" at the end.

 

It will say:

File c:/geant4/geant4_8_0_p01/data/PhotonEvaporation2.0 doesn't exist.  Use that name anyway?

Enter: y

 

You will have to repeat this procedure for one more data file as follows.

When it says:

Please, specify default directory where the Geant4 data is installed:

Enter: 2

 

It will then ask:

Where is Geant4 RadiativeDecay data installed?

Enter something like: c:/geant4/geant4_8_0_p01/data/RadiativeDecay3.0

That is, give it what it had suggested for the default but add on a "3.0" at the end.

 

It will say:

File c:/geant4/geant4_8_0_p01/data/RadiativeDecay3.0 doesn't exist.  Use that name anyway?

Enter: y

 

Once more you will see:

Please, specify default directory where the Geant4 data is installed:

 

You are done correcting the data file locations.

Hit enter to accept the values as they now stand.

 

Next, it will say:

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

 

It will then tell you:

You can customize paths and library name of your CLHEP installation:

Enter: 3

 

It will then ask you:

What is CLHEP lib title?

 

Enter: CLHEP.lib

 

It will then tell you again:

You can customize paths and library name of your CLHEP installation:

Take the default (meaning you are done making changes to this set of items).

 

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_8_0_p01/.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_8_0_p01/.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_8_0_p01

On this machine the G4TMP=c:/geant4/geant4_8_0_p01/tmp

On this machine the G4LIB=c:/geant4/geant4_8_0_p01/lib

On this machine the G4LEVELGAMMADATA=c:/geant4/geant4_8_0_p01/data/PhotonEvaporation2.0

On this machine the G4RADIOACTIVEDATA=c:/geant4/geant4_8_0_p01/data/RadiativeDecay3.0

On this machine the G4LEDATA=c:/geant4/geant4_8_0_p01/data/G4EMLOW3.0

On this machine the NeutronHPCrossSections=c:/geant4/geant4_8_0_p01/data/G4NDL3.7

On this machine the G4ELASTICDATA=c:/geant4/geant4_8_0_p01/data/G4ELASTIC1.1

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 G4LIB_BUILD_STATIC=1

On this machine the G4LIB_USE_GRANULAR=1

 

Starting build...

 

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

 Installation Geant4 version : geant4-08-00-patch-01

                            Copyright : 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/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/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/G4Exception.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 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_8_0_p01/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.  The latest version, 3.81-1, does not work for Geant4.  You instead need the previous version, 3.80-1. Go back to the above instructions about installing Cygwin, rerun the "setup.exe" utility that you already downloaded, and follow the above instructions about how to select the specific version of make.  Cygwin does a nice job of remembering what you have already installed and will not make you download everything all over again.  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.

 

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_8_0_p01/.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...

 

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

# Your Geant4 installation seems to be successful!

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

# /cygdrive/c/Geant4/geant4_8_0_p01/.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.  You should have selected "File Type: Unix / binary".

What you really need to do now is delete everything and go all the way back to "Getting and Installing Cygwin".

 

A few users have encountered problems early in their compilation that say something about a missing "windows.h".  If you see such errors, you have a problem with your copy of windows or with your PlatformSDK installation.  Do not ignore this error - it is not survivable.  The Microsoft forum at:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=7004&SiteID=1

suggests the following fix, which might help:

  1. Create a directory "PlatformSDK" under "%ProgramFiles%\Microsoft Visual Studio 8\VC"
  2. Copy the "bin", "include" and "lib" directory from the PSDK-installation into this directory.

 

Creating the setup script

 

The configure process has set up some environment variables that you will want to have in future sessions.  Have configure make you an environment setup script 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_8_0_p01 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

 

Be sure to specify the G4WORKDIR using the c:/ notation rather than the Cygwin-specific notation, /cygdrive/c.  The make utility does not understand the /cygdrive/c notation.

 

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_8_0_p01/examples/novice

or the analysis example

c:/Geant4/geant4_8_0_p01/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_8_0_p01/env.sh

 

It will respond:

On this machine the G4SYSTEM=WIN32-VC

On this machine the G4INSTALL=c:/geant4/geant4_8_0_p01

On this machine the G4LIB=c:/geant4/geant4_8_0_p01/lib

On this machine the G4LEVELGAMMADATA=c:/geant4/geant4_8_0_p01/data/PhotonEvaporation2.0

On this machine the G4RADIOACTIVEDATA=c:/geant4/geant4_8_0_p01/data/RadiativeDecay3.0

On this machine the G4LEDATA=c:/geant4/geant4_8_0_p01/data/G4EMLOW3.0

On this machine the NeutronHPCrossSections=c:/geant4/geant4_8_0_p01/data/G4NDL3.7

On this machine the G4ELASTICDATA=c:/geant4/geant4_8_0_p01/data/G4ELASTIC1.1

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 G4LIB_BUILD_STATIC=1

On this machine the G4LIB_USE_GRANULAR=1

In your environment you have the G4WORDIR=c:/g4work

 

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

source c:/Geant4/geant4_8_0_p01/env.csh

or

cd c:/Geant4/geant4_8_0_p01/

./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:

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/A01TrackingAction.cc ...

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

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

 

And ending with:

Compiling A01app.cc ...

A01app.cc

Using granular libraries ...

Linking A01app ...

cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release

cl : Command line warning D9024 : unrecognized source file type 'c:/geant4/tmp/WIN32-VC/A01app/exe/A01app.o', object file assumed

 

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.

 

When 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_8_0_p01/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-08-00-patch-01    (10-February-2006)

                      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)

  GAGTree (GAGTree)

  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/scene/create

/vis/open OGLSWin32

 

You will get the following response:

WARNING: objects with visibility flag set to "false" will not be drawn!

  "/vis/viewer/set/culling global false" to Draw such objects.

  Also see other "/vis/viewer/set" commands.

G4Scene::AddWorldIfEmpty: The scene was empty,

   "world" has been added.

 

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

 

Do not accidentally type:

/vis/open OGLIWin32

This version of the OpenGL driver has problems.

You should only use:

/vis/open OGLSWin32

 

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:

 

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

exit

 

If you don't see the trajectories and hits, but instead just see an empty detector, it may be that you forgot to replace the flawed copy of G4OpenGLWin32Viewer.cc as described in the section above, "Getting Geant4".

To tell if this is really the problem, try running several events in a row, as in:

/run/beamOn 10

You should notice that the trajectories flash briefly on the screen after each event but are then removed.

Replace G4OpenGLWin32Viewer.cc as described above.

Then remake the OpenGL library and remake your example as follows:

cd $G4INSTALL/source/visualization/OpenGL

make clean

make

cd $G4WORKDIR/A01

touch A01app.cc

make

 

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 WIRED3 HepRep Browser:

$G4WORKDIR/bin/WIN32-VC/A01app

/vis/scene/create

/vis/open HepRepFile

/vis/viewer/flush

/vis/scene/add/trajectories

/vis/scene/add/hits

/run/beamOn 1

 

For more details on using WIRED3 for Geant4, see:

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

 

Note: WIRED3 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 Wired3, or you can simply make the .heprep file visible from the web, and let Wired pick it up via the url.

Also note that the .heprep file can be zipped to about 5 percent of original size and Wired3 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 two lines:

#elif defined(G4UI_USE_WIN32)

session = new G4UIWin32()

 

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.

 

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".

 

For Geant4, when ./Configure -build asks you to "Specify the path where Geant4 libraries and source files should be installed", specify whatever area you want instead of taking the default.  When you are asked about the CLHEP library, be sure to specify the same location that you specified during the CLHEP installation.  Then, after you've installed Geant4 as described below, issue an additional command (as root user), ./Configure -install.

 

 

I hope these instructions have been helpful.

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

 

Joseph Perl

Stanford Linear Accelerator Center

20 March 2007