Software/Geant4/Eclipse

From PBTWiki
Revision as of 17:16, 5 September 2018 by SaadShaikh (talk | contribs) (→‎Using ROOT in Eclipse)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Editing Geant4 input files in Eclipse.

Why use Eclipse

Eclipse allows for editing files remotely using an environment that gives rudimentary debugging tools and a simple remote file explorer. Furthermore, this method supports remote file editing on an operating system that does not have native access to the bash terminal (i.e. Windows).

It should be noted that this tutorial is written with the C/C++ Oxygen version of the Eclipse IDE in mind, as the Remote System Explorer plug-ins are included in this package, but the tutorial should work for other packages. All of the current eclipse packages can be found here.

Connecting via SSH

Once you have downloaded, installed, and launched Eclipse, you will want to SSH into the plus1.hep.ucl.ac.uk server. This is done by the following steps:

1) Open the Remote System Explorer (RSE). This is done by going to Window > Perspective > Open Perspective > Other, and then choosing Remote System Explorer. (Note: If it is not visible, it can be installed by Help > Install New Software > Work with: All Available Sites, and then searching Remote System Explorer.

2) In the Panel containing the Remote Systems tab that appeared when the RSE was opened, define a new connection. This can be done by clicking the icon at the top of the panel, or right clicking on the panel and selecting New > Connection.

3) In the New Connection window that opened, select the 'SSH Only' System type.

4) In the hostname text box, enter the server address that you want to SSH into. For use with the pbt server, enter

plus1.hep.ucl.ac.uk

and give the connection a name, for example plus1.

5) In the Remote Systems panel opened earlier, you should see a new connection with then connection name you chose earlier. Opening the tree from Stfp Files > Root, you will be prompted to enter a User ID and password. In their respective text boxes, enter your pbt User ID and Password. You are now connected remotely to the plus1 server.*

  • It should be noted that you cannot subsequently SSH from the plus1 server into another pc in the pbt cluster using this method.

Alternative methods to do so are discussed in the Running a SSH Shell in Eclipse section.


Using ROOT in Eclipse

1) Verify that you have a correct installation of ROOT on your computer.

2) In a terminal window, type in the commands root-config --cflags and also root-config --glibs . We will be using the output of these commands to get Eclipse to know where ROOT's libraries are.

3) Create a new C/C++ project in Eclipse and open the project preferences. Go to C/C++ Build -> Settings.

4) Under the C++ linker settings, in the libraries window, add in the -l flags listed in the terminal output of the --glibs command. Add them one-by-one and in order, without the -l prefix. e.g. Gui, Core, Imt, etc. (Careful with casing!)

5) In the library search path, add in the path shown in the terminal output of the --glibs command, without the -L prefix. e.g. /Applications/root_v6.14.00/lib

6) Under the miscellaneous options for the linker, add into the linker flags the flags output from the --cflags command. e.g. -pthread -stdlib=libc++ -std=c++11 -m64

7) Under the C++ compiler settings, in the Includes settings, add the subsequent path output from the --cflags command into the Includes path. e.g. /Applications/root_v6.14.00/include

8) Under optimisation for the compiler settings, add in the linker flags mentioned in step 6 into the optimisation flags box. Also change the optimisation level to "Optimise most".

9) If you have library search path errors, you may need to set the environment variables in C/C++ Build settings -> Environment.

10) Add in the variable: LD_LIBRARY_PATH with the value of the library path for ROOT, e.g. /Applications/root_v6.14.00/lib

11) Add in the variable: ROOTSYS with the value of the location of the ROOT folder, e.g. /Applications/root_v6.14.00

12) ROOT should now work within Eclipse, allowing you to write pre-compiled code with all of Eclipse's features.

Using Eclipse

Remote System Details

You can open a panel that displays details about the remote systems you have connected to. This is done from Window > Show View > Remote System Details. You can use this window in a manner similar to the Remote Systems file explorer panel, except that the Remote System Details panel gives more detail about the files contained (for example the time stamp of the last time the directory/file was edited etc). You can use the buttons at the top right of this panel to navigate through the server's directories.

Easier File management

Instead of using a bash terminal, you can use the tree within the Remote Systems panel to move, copy, and open files. This is done by simple highlighting the file, right clicking, and selecting the required operation (copy/cut/delete etc.). It should be noted that this method of file management is significantly slower than performing the same action via a terminal.

Running an SSH Shell in Eclipse

You can also open a bash terminal in Eclipse. In the Remote Systems panel, under the SSH connection you have created, you will see a subdirectory called 'SSH Shells'. Right click this and select Launch Shell. This shell allows connections to internal PCs in the UCL HEP cluster, as well as the ability to perform all other standard bash commands on the pbt server.