Ns-3 on Visual Studio 2012: Difference between revisions
Jump to navigation
Jump to search
Line 65: | Line 65: | ||
== Adding a new module == | == Adding a new module == | ||
To create your own module do the following: | To create your own module do the following: | ||
* Right-click on the "Solution ns-3-dev" and select Add --> "New Project" | * '''Create an empty C++ project''' | ||
* In the dialog that follows select "Visual C++"--> "Empty Project" as the type of project. | ** Right-click on the "Solution ns-3-dev" and select Add --> "New Project" | ||
* Enter the name of your module such as "MyModule" and click OK. | ** In the dialog that follows select "Visual C++"--> "Empty Project" as the type of project. | ||
* From the solution view, right-click on the new project ("MyModule") and select "Properties" | ** Enter the name of your module such as "MyModule" and click OK. | ||
* '''Set the path to find headers:''' Under "Configuration Properties" --> "C/C++" --> "General" --> "Additional Include Directories" on the right-pane append the value "$(SolutionDir)\headers;" to specify the location of other ns-3 headers | * '''Open the properties page''' | ||
* '''Set Preprocessor defintions:''' Under "Configuration Properties" --> "C/C++" --> "Preprocessor" --> "Preprocessor definitions" on the right-pane append the value "WIN32" | ** From the solution view, right-click on the new project ("MyModule") and select "Properties" | ||
* '''Set the module as a static library:'''Under "Configuration Properties" --> "General" --> "Project Defaults" (on the right-pane) --> "Configuration Type" --> set the value to "Static Library (.lib)" | * '''Set the path to find headers:''' | ||
* '''Move your modules header files to the common headers location:''' Under "Configuration Properties" --> "Build Events" --> "Post-Build Events" --> "Command Line" (on the right-pane) --> Add the following lines to move your API's model and helper headers to the common ns-3 header location. | ** Under "Configuration Properties" --> "C/C++" --> "General" --> "Additional Include Directories" on the right-pane append the value "$(SolutionDir)\headers;" to specify the location of other ns-3 headers | ||
* '''Set Preprocessor defintions:''' | |||
** Under "Configuration Properties" --> "C/C++" --> "Preprocessor" --> "Preprocessor definitions" on the right-pane append the value "WIN32" | |||
* '''Set the module as a static library:''' | |||
** Under "Configuration Properties" --> "General" --> "Project Defaults" (on the right-pane) --> "Configuration Type" --> set the value to "Static Library (.lib)" | |||
* '''Move your modules header files to the common headers location:''' | |||
** Under "Configuration Properties" --> "Build Events" --> "Post-Build Events" --> "Command Line" (on the right-pane) --> Add the following lines to move your API's model and helper headers to the common ns-3 header location. | |||
<pre> | <pre> | ||
copy "$(SolutionDir)\..\..\src\MyModule\model\*.h" "$(SolutionDir)\headers\ns3" | copy "$(SolutionDir)\..\..\src\MyModule\model\*.h" "$(SolutionDir)\headers\ns3" |
Revision as of 18:38, 29 September 2013
Prerequisites
- Visual Studio Express 2012 for C++
- Visual Studio Express 2012 for C++ can be downloaded from http://www.microsoft.com/visualstudio/eng/downloads
Please note: Visual Studio 2010 is not supported
- Mercurial
- Mercurial can be downloaded from http://mercurial.selenic.com/
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"
If all goes well 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".
The executable can be run from the command-prompt by
C:\>cd windows\ns-3-dev\Debug ..Debug>main.exe
.
Changing the main program
To replace the default main program in the "main" project. Do the following:
- Select the "main" project
- Expand the "Source Files" filter
- Right-Click on the existing .cc file, which in a new installation is "third.cc" and select "Remove"
- Right-Click on "Source Files" --> "Add"
- In the popup-menu select "Existing Item" to add an existing source file or select "New Item" to create a new source file.
- 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:
- Create an empty C++ project
- 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 "MyModule" and click OK.
- Open the properties page
- From the solution view, right-click on the new project ("MyModule") and select "Properties"
- Set the path to find headers:
- Under "Configuration Properties" --> "C/C++" --> "General" --> "Additional Include Directories" on the right-pane append the value "$(SolutionDir)\headers;" to specify the location of other ns-3 headers
- Set Preprocessor defintions:
- Under "Configuration Properties" --> "C/C++" --> "Preprocessor" --> "Preprocessor definitions" on the right-pane append the value "WIN32"
- Set the module as a static library:
- Under "Configuration Properties" --> "General" --> "Project Defaults" (on the right-pane) --> "Configuration Type" --> set the value to "Static Library (.lib)"
- Move your modules header files to the common headers location:
- Under "Configuration Properties" --> "Build Events" --> "Post-Build Events" --> "Command Line" (on the right-pane) --> Add the following lines to move your API's model and helper headers to the common ns-3 header location.
copy "$(SolutionDir)\..\..\src\MyModule\model\*.h" "$(SolutionDir)\headers\ns3" copy "$(SolutionDir)\..\..\src\MyModule\helper\*.h" "$(SolutionDir)\headers\ns3"