# Installation and Set-Up

The easiest way to install the OProfile plug-in for Eclipse is through the '' Software Updates and Add-ons '' menu. For information on how to use this menu, refer to http://wiki.eclipse.org/Linux_Tools_Project/PluginInstallHelp#Installing_Updates_From_the_Linux_Tools_Update_Site.

Unlike most Eclipse plug-ins, the OProfile plug-in requires some configuration after installation. Note that this configuration process takes only a few simple steps, and only needs to be done once.

After the plug-in is first installed, performing a profile run with OProfile will bring up a dialog similar to the following:

As the dialog suggests, you must run the supplied install script; this script will allow the OProfile plug-in to perform OProfile tasks as root (since OProfile cannot be run as an unprivileged user). The steps below are the same as the dialog but described in more detail.

To avoid having to perform the installation setup users can create a launch configuration for their project that uses 'operf' instead of 'opcontrol'. Simply navigate to either the Profiling/Profiling Tools launch configuration dialog and create an OProfile launch configuration. Select the OProfile Global Settings tab, and select 'operf' from the 'Profile With' combo box. In future releases, 'operf' will become the default option.

## Step 1 - Locate the Installation Scripts

Open up a terminal and locate the `natives/linux/scripts` subdirectory, which is found in the `org.eclipse.linuxtools.oprofile.core` plug-in directory. The location of this plug-in directory depends on how you installed Eclipse.

- If you are using a distro-supplied version of Eclipse and installed the plug-in via the update site, the plug-in directory will most likely be under `~/.eclipse`. To find the exact location of the plug-in directory in this case, use the following command:
- `find ~/.eclipse -name 'org.eclipse.linuxtools.oprofile.core_*'`
- Alternatively, if you are using an extracted tarball of Eclipse (i.e. you downloaded a `.tar.gz` from http://www.eclipse.org/downloads/), then the plug-in will most likely be in the `plugins` sub-directory of where you extracted it.
- For example, if you extracted the tarball to `/home/ksebasti`, your Eclipse installation would be in `/home/ksebasti/eclipse`. In this case, you should use the following command to find the exact location of the plug-in directory:
- `find /home/ksebasti/eclipse -name 'org.eclipse.linuxtools.oprofile.core_*'`

Note: In both cases, the quotes (') and asterisk (*) are necessary.

Sample output will look like this:

    $ find /home/ksebasti/eclipse -name 'org.eclipse.linuxtools.oprofile.core_*'
    /home/ksebasti/eclipse/plugins/org.eclipse.linuxtools.oprofile.core_0.2.0.200904131051

Once you find the plug-in directory, navigate to its `natives/linux/scripts` subdirectory. Using our previous example:

    $ cd /home/ksebasti/eclipse/plugins/org.eclipse.linuxtools.oprofile.core_0.2.0.200904131051/natives/linux/scripts

The `natives/linux/scripts` subdirectory contains the installation scripts you will need to run in order to allow OProfile to run as root.

## Step 2 - Choose Which Installation Script To Run

The `natives/linux/scripts` subdirectory contains two scripts: `install.sh`, and `install-noconsolehelper.sh`. These scripts perform sanity checks to ensure OProfile is installed. The difference is in how root authentication with the plug-in is set up.

- `install.sh` uses PolicyKit. This is the default and recommended method for root authentication. When an OProfile task is required, you will be presented with a dialog to enter the root password. If PolicyKit is not installed on the system, it is recommended to use `install-noconsolehelper.sh` instead.
- `install-noconsolehelper.sh` can be used when `PolicyKit` is not present on the system. It uses the sudo mechanism and a small wrapper script. The install script will describe the text which should be written in the `sudoers` file, then run the command `visudo` to edit it.
  Warning: The `sudoers` file is a sensitive system file and altering it in other ways may lead to system instability. Only users with enough knowledge of running a Linux system should use this method. For these reasons, this method of root authentication is discouraged. However, it may be the only option available to some users and it has been tested to work by developers and users of the plug-in.

## Step 3 - Running The Install Script

Once you have selected an install script, log in as root. Assuming you are in the `natives/linux/scripts` subdirectory of the plug-in directory (as in Step 1 - Locate the Installation Scripts), run your selected install script:

     # ./install.sh

Successful output will look like this:

    ./install.sh
    Eclipse-OProfile plugin install successful.

Install scripts should be run as the root user since these scripts perform some actions that require elevated privileges: `install.sh` uses PolicyKit, and `install-noconsolehelper.sh` runs the command `visudo`. If you wish to simply run either install script without logging in as root, use:

     su -c './install.sh'

This command will run only the install script as the root user, then return control to the regular user. Note that you will still need to enter the root password to make this work. If you receive an error message, refer to the Troubleshooting section.

## Step 4 - Restart Eclipse

After running the install script, restart Eclipse using File > Restart.

If you need to uninstall the plug-in, run the uninstall script that corresponds to the install script used. For example, if you used `install.sh`, you would run `uninstall.sh` before uninstalling it from within Eclipse. These scripts are also located in the `natives/linux/scripts` subdirectory of the OProfile core plug-in directory (i.e. the same directory where the install scripts are found).