Difference between revisions of "Ns-3 on Visual Studio 2012"

From Nsnam
Jump to: navigation, search
(Adding a new module)
(Adding a new module)
Line 69: Line 69:
 
* Enter the name of your module such as "My Module" and click OK.
 
* Enter the name of your module such as "My Module" and click OK.
 
* From the solution view, right-click on the new project ("My Module") and select "Properties"
 
* From the solution view, right-click on the new project ("My Module") and select "Properties"
 +
* Under "Configuration Properties" --> "C/C++" --> "Additional Include Directories" on the right-pane append the value "$(SolutionDir)\headers;" to specify the location of other ns-3 headers
 
[[File:New project.png|thumbnail|left|Add a "New Project"]][[File:Empty project.png|thumbnail|center|Create an empty project named "My Module"]][[File:Properties.png|thumbnail|right|Properties page]]
 
[[File:New project.png|thumbnail|left|Add a "New Project"]][[File:Empty project.png|thumbnail|center|Create an empty project named "My Module"]][[File:Properties.png|thumbnail|right|Properties page]]
 +
[[File:Additional include.png|thumbnail|left|Set Additional Include directories]]
  
 
== Design of the solution ==
 
== Design of the solution ==

Revision as of 01:21, 25 September 2013

Prerequisites

Please note: Visual Studio 2010 is not supported

How to download

The ns-3 package is available for download using mercurial using the command below

hg clone http://code.nsnam.org/jabraham3/ns-3-win2

How to build

Open the solution file "ns-3-win2/windows/ns-3-dev/ns-3-dev.sln" using Visual Studio 2012. After all the projects are loaded do the following:

  • From the menu click "Build" --> "Build Solution"
Click Build--> Build Solution

If all goes we should see a build log similar to the below

1>  main.vcxproj -> C:\ws\test\ns-3-win2\windows\ns-3-dev\Debug\main.exe
========== Build: 1 succeeded, 0 failed, 34 up-to-date, 0 skipped ==========

Running the main program

The "main" project is set as the "Startup" project. The "Startup" project contains the program with the 'main' function. The main project is set to run "third.cc".

Default program is third.cc


The executable can be run from the command-prompt by

C:\>cd windows\ns-3-dev\Debug
..Debug>main.exe


executing main.exe








.

Changing the main program

To replace the default main program in the "main" project. Do the following:

  1. Select the "main" project
  2. Expand the "Source Files" filter
  3. Right-Click on the existing .cc file, which in a new installation is "third.cc" and select "Remove"
  4. Right-Click on "Source Files" --> "Add"
  5. In the popup-menu select "Existing Item" to add an existing source file or select "New Item" to create a new source file.

Changing the current main program

  1. At this point you can repeat the #How to build steps above to build the solution.

Adding a new module

To create your own module do the following:

  • Right-click on the "Solution ns-3-dev" and select Add --> "New Project"
  • In the dialog that follows select "Visual C++"--> "Empty Project" as the type of project.
  • Enter the name of your module such as "My Module" and click OK.
  • From the solution view, right-click on the new project ("My Module") and select "Properties"
  • Under "Configuration Properties" --> "C/C++" --> "Additional Include Directories" on the right-pane append the value "$(SolutionDir)\headers;" to specify the location of other ns-3 headers
Add a "New Project"
Create an empty project named "My Module"
Properties page
Set Additional Include directories

Design of the solution