Message: Re: Using Geant4 libraries in Eclipse Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Using Geant4 libraries in Eclipse 

Keywords: install, configure, eclipse, library, use
Forum: Installation and Configuration
Re: Question Using Geant4 libraries in Eclipse (Paul Anton)
Date: 12 Oct, 2007
From: Ben Morgan <Ben Morgan>

Hi Paul,

I've been able to use Eclipse for Geant4 work, although it perhaps doesn't use the full capabilities of Eclipse (more experienced Eclipse users may want to comment here). It's also Linux-specific, although it should be possible to adapt the method to Windows. What I did was the following:

1) Create a new Standard Make C++ project in your chosen workspace.

2) In the project, create subdirectories include and src, as per a 'standard' Geant4 project.

3) Create a 'standard' Geant4 makefile for the project as per the examples.

4) Create a shell script in the top level project directory called, say, g4eclipsemake, which contains:

 #!/bin/sh
 source <path to your g4 installation or env scripts>/env.sh
 G4WORKDIR=`pwd`
 gmake $1

The change in workdir is optional - I just do that to keep everything together

5) in Project->Properties, go to C/C++ Make Project, and change the build command to

 ${project_loc}/g4eclipsemake

(or whatever you named the script) I -think- that's all I did here.

6) You can now try building - hopefully everything works :).

7) To run the application, I used a similar process, create a shell script in the top level project directory called, say, g4eclipserun, containing

 #!/bin/sh
 source <path to your g4 installation or env scripts>/env.sh
 G4WORKDIR=`pwd`
 $G4WORKDIR/bin/$G4SYSTEM/<name of your project executable>

As above, the change in workdir is optional.

8) In Run->Run, choose C/C++ Local Application, and in the Main tab change the the C/C++ Application to

 g4eclipserun

(or whatever you named your script)

You can then run, and Eclipse will run your application, even using the Eclipse terminal. Whilst you can interact with your application here, it's not as fully functional as the standard terminal. To get around this, you could use one of the Geant4 graphical UIs such as G4UIXm, or the script above can be modified to:

 #!/bin/sh
 source <path to your g4 installation or env scripts>/env.sh
 G4WORKDIR=`pwd`
 xterm $G4WORKDIR/bin/$G4SYSTEM/<name of your project executable>

which will start the executable in a new xterm...

As I said above, this is a bit of a hack - it's nothing more than a wrapper around the Geant4 build system. More experienced Eclipse users may have better ideas...

One nice thing with the above is that by editing the make/run scripts, you can swap between Geant4 versions quite easily by changing which env.sh file gets sourced - although a make clean is necessary first.

Anyway, hope that is of some help :)

Cheers,

Ben.

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

1 None: Re: Using Geant4 libraries in Eclipse   (Paul Anton - 16 Oct, 2007)
1 None: Re: Using Geant4 libraries in Eclipse   (Ben Morgan - 18 Oct, 2007)
(_ None: Re: Using Geant4 libraries in Eclipse   (Paul Anton - 18 Oct, 2007)
(_ None: Re: Using Geant4 libraries in Eclipse   (Paul Anton Letnes - 22 Nov, 2007)
5 Idea: Re: Using Geant4 libraries in Eclipse   (Jonathan Aguilar - 03 Mar, 2009)
1 None: Re: Using Geant4 libraries in Eclipse   (John Allison - 04 Mar, 2009)
 Add Message Add Message
to: "Re: Using Geant4 libraries in Eclipse"

 Subscribe Subscribe

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


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