Install and configure Eclipse IDE to use with ns3 on Ubuntu

First, you need to download Eclipse CDT (C/C++ Development Tooling):

sudo apt-get install eclipse-cdt eclipse-mercurialeclipse

Maybe, you will have problems to run eclispse and it will close:

An extract of the log:

org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.simpleconfigurator_1.0.301.dist [1]" could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4

!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.simpleconfigurator_1.0.301.dist.jar was not resolved.
!MESSAGE Missing required capability Require-Capability:; filter="(|(&("

To solve it, you must change your java version to other compatible with eclipse. In my case, I was using openjdk9, and I switch it for openjdk8-jre.

sudo apt-get install openjdk-8-jre
sudo update-alternatives --config java

Start Eclipse and from the File menu select New > Project... to start a new project wizard.

Select C++ Project and click Next.

Uncheck Use default location and enter the path to ns3-dev folder in the Location text box. 

Complete the wizard and you should see the ns-3 project loaded in the Project Explorer.

From the Project Explorer, right click on the project name and select Properties from the context menu. In the Properties dialog, go to C/C++ Build.

Uncheck Use default build command and enter the path to waf in the Build command text box (bake/source/ns-3-dev/waf)

Uncheck the Generate Makefiles automatically and enter the path to build in the Build directory text box (bake/source/ns-3-dev/build)

Switch to the Behavior tab.

Change all by build in the Build (incremental build) text box build. Afterwards, click Ok to apply the changes.

Now, you need create a new environment variable to run your simulations

From the Run menu, select Debug configuration. Under C/C++ Application, select the project. 

Click the Search Project... button. Find and select scratch-simulator then switch to the Environment tab.

Click the New... button to create a new environment variable
Enter the following variable name in the Name text box
Enter the following paths in the Value text box and click OK button.
Apply the changes before closing the Debug Configuration window and run the program. It should print Scratch Simulator as shown below.

If you want run your simulation quickly, other way to do it is through external tools:

Add an external builder (Run->External Tools->External Tools Configuration) and add a new Program. Then you can configure it:
  • Location = your waf location (i.e. /home/x/workspace/ns-3-dev/waf)
  • Working Directory = your ns3 directory (i.e. /home/x/workspace/ns-3-dev/)
  • Arguments = --run "${string_prompt}"

When you will run a simulation (like , click on ns3 icon (play with a toolbox icon) and put the name of your file like an argument.
The result of your simulation will print on your Console tab.


  1. thank you a billion for the solution:
    sudo apt-get install openjdk-8-jre
    sudo update-alternatives --config java


Post a Comment

Popular posts from this blog

How to fix Android when developer options are not available for this user

from: can't read /var/mail/ in Python scripts

Fix "Set scan parameters failed: Input/output error" on Ubuntu 16.04